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.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With