Is there a way to show a Compose popup or dialog from an Android custom view?
We have lots of Android custom views that we don't have the time to migrate fully to compose, but we are adding new developments in compose gradually. Adding
ComposeView
in the XML works for most cases, but now we have to show a pop window and an alert on user interaction.
We have tried creating the
PopupWindow
and
AlertDialog
programmatically and setting the content view as a
ComposeView
with the desired content but we get errors like:
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from android.widget.PopupWindow$PopupDecorView
So we are thinking that maybe there is a way to launch the alert and popup directly from compose, but don't know how to launch it from inside a custom view without replacing the already working content.