Akshay
Akshay

Reputation: 5765

Android: Dismissing a dialog before displaying another

My application displays alert dialogs in some cases. Also, it is possible for a user to launch my application using the VIEW/SEND intent. The scenario I am considering is, the dialog is visible, the user presses 'Home' & selects my application to View/Share a file.

I would want to dismiss the dialog before beginning with the view/share operation. Although I can maintain which dialog is visible and hide it before the operation begins, I was wondering if there is a conventional/recommended way or API, something like activity.dismissAnyVisibleDialog() that can come in handy.

Thanks a lot,

Akshay

Upvotes: 1

Views: 512

Answers (2)

Akshay
Akshay

Reputation: 5765

I finally myself maintained which dialog is visible & dismissed it before displaying the next one.

-Akshay

Upvotes: 2

pumpkee
pumpkee

Reputation: 3357

Just close the dialog in the onPause() method (override in your activity). This way it will be dismissed when the activity is no longer visible i.e if you switch to the home screen.

Upvotes: 0

Related Questions