Issue
When I am starting an Activity
, I am passing some data to. it via the Intent
. How can I access this data from Intent inside a composable?
I am looking for a way to directly access the Intent
from a composable.
Solution
You can get current activity from the LocalContext
. And this using activity you can get intent:
val context = LocalContext.current
val activity = context.findActivity()
val intent = activity?.intent
findActivity
:
fun Context.findActivity(): Activity? = when (this) {
is Activity -> this
is ContextWrapper -> baseContext.findActivity()
else -> null
}
Answered By - Phil Dukhov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.