I know we can use composeView to have compose code in the legacy code, but is there any way to use Jetpack Compose Dialog inside java code (especially in a fragment)?
I saw this post Possible to use/layout a compose view in and Activity written in Java? but this is not answer of this question.
I want to show a Jetpack Compose Dialog inside onActivityResult of a fragement in java code!
You have to use
ComposeViewas indicated in the other question, but make it irrelevant to the layout. Then usesetContentto control the dialog.The trick is the width and height are zero, so it doesn't use space or break the layout.
You have to control the visibility with something else like a field in the fragment or in the view model.
And inside the compose dialog, make that
showDialog.value = falsewhen you need to dismiss it.