Jim
Jim

Reputation: 9234

Android: The AlertDialog is invisible when the Activity back to foreground

This question is related to The AlertDialog is invisible when the Activity back to foreground post.

I have the same problem. The previous post is old, and have no answer. Any suggestions how to solve that problem ? Thanks...

Upvotes: 1

Views: 1130

Answers (3)

Laurent'
Laurent'

Reputation: 2631

Also we all create Dialogs on the fly whenever we need them, we should not.

Android way is (by the book) to override an onCreateDialog(int) and showDialog(int) in our activities so that our dialogs can be managed by the activity lifecycle.

Another way to do so is to use myDialog.setOwnerActivity(MyActivity.this) to tell the dialog it is managed by the activity.

Upvotes: 0

Sherif elKhatib
Sherif elKhatib

Reputation: 45942

For some reason, Dialogs' states must be handled by the developer.

Simply keep a reference to the dialog showing

For example

Dialog showingDialog=null;

Now in onResume()

if(showingdialog!=null)
    //show the dialog and maybe resume some state

Upvotes: 1

jjNford
jjNford

Reputation: 5270

Have you tried to re-display the AlertDialog when in the activities onResume(). Using Google developers example you would be able to create an instance of this dialog and just recall it.

http://developer.android.com/guide/topics/ui/dialogs.html#AlertDialog

Hope that helps.

Upvotes: 0

Related Questions