Rafiul Islam
11/07/2021, 2:12 PMval activity = LocalContext.current as Activity
But I never found the answer.Adam Powell
11/07/2021, 3:56 PMLocalContext
is not an Activity
, but instead it can be a chain of `ContextWrapper`s where the .baseContext
leads to an Activity
eventuallyContextThemeWrapper
has been used to change the theme mid-view hierarchy. If you use the android:theme
attribute in layout xml, one of these is created for you. If a ComposeView
is placed as a child of such a subtree, LocalContext
will be one of these wrappers.() -> Unit
callback or similar to your composable and provide a lambda that makes the actual activity call. This can often aid in testabilityRafiul Islam
11/07/2021, 4:44 PMAdam Powell
11/07/2021, 4:57 PMContextThemeWrapper
around a Service
context, getSystemService
to get the WindowManager
, and add a ComposeView
to it as a top-level window with the right lifecycle dependencies configured. At that point you have no activity, but you have a perfectly functional compose uiRafiul Islam
11/07/2021, 5:07 PM