i need the fragment context for some legacy dialog...
# compose
m
i need the fragment context for some legacy dialogs inside a composable.
Copy code
LocalContext.current
is not returning me the fragment context. Is there a way to get it, without passing the context explicitly?
i think i got it. I was passing wrong context in ComposeView
c
Fragments don't extend
Context
like an
Activity
does, so
LocalContext
will never give you a reference to a Fragment.
m
ya. but i’m using a themed context (contextThemeWrapper) in the composeView because i need different context based on the fragment. For some reason, its not using that context
a
Here's how it assigns
LocalContext
- it comes from the view, so it should be whatever context you've used to construct the view: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]tionLocals.android.kt;l=116?q=ProvideAndroidCompositionLocals
m
thanks @Adam Powell. I managed to find it 😛