I have an activity where I start the built-in camera using onActivityResult. After taking a picture, I go back to my application and show a pop up asking to the user if he wants to take more pictures or no. It works fine, but after taking the picture, when I press the “save” button on the built-in camera app, and inmediatly I press the home button, If I go back to my application, my activity is visible but not active and the popup that should be visible is there but I cannot see it. If I press the back button and cancel the pop up, my activity is active again, but I dont want to allow the user cancelling the pop up, so when this behavior occurs, I cannot use my app, I just have to kill it…
The question is, how can I force to the dialog being always on the top if it is shown? Cause seems like it is behind the activity, waiting for the user to interact with it…
Thanks!
The easiest way I’ve found to fix this is to track the lifetime of the dialog in the activity and do a
hide()/show()in theonResumefor the activity. This solution only works for a singleDialogup at a time but could easily be adapted to more if required.1) Make your activity implement
Dialog.OnDismissListener.2) Add an instance variable for the current
Dialogin yourActivity:3) In
onResume()add:4) For each dialog created in
onCreateDialog(), add:5) Finally, add:
That seems to fix it for me.