Can I use ```val context = +ambient(ContextAmbient...
# compose
b
Can I use
Copy code
val context = +ambient(ContextAmbient)
from a composable nested within setViewContent{ }? Currently seem to be getting an NPE because of this. Is there an alternative way of getting context? EDIT: Currently I'm doing this from my activity to get context to a listener into my composable function.
Copy code
val context: Context = this
setViewContent {
        MapApp(context = context)
}
l
what code is giving you the NPE?
ohhh
i gotcha
we should fix this. can you file a bug?
in the meantime, you can do something like this….
Copy code
fun Activity.mySetViewContent(content: @Composable () -> Unit) = setViewContent { ContextAmbient.Provider(this, content) }
but you shouldn’t have to do that… we just haven’t provided all of the ambients we should have been in the
setViewContent
utility function
👍🏻 1
b
sure. and gotcha, i'll do that for now. thanks!