Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you fire an event when Android Dialog is dismissed?

Say I have a created a dialog in my Android app like so:

private static ProgressDialog dialog;
dialog = ProgressDialog.show(MainActivity.this, "", "Downloading Files. Please wait...", true);

Now, is it possible to fire an event when the following is called?

dialog.dismiss();

The reason I want to do this and not just call my method after dialog.dismiss(); is because the Dialog dismiss is called within a static class and the next thing I want to do is load a new Activity (which cannot be done using Intents within a static class).

like image 546
ingh.am Avatar asked Jun 01 '11 15:06

ingh.am


People also ask

How do you check dialog is dismissed or not?

For me onCancelListener was the best option since I needed something that tracked an explicit closing of the dialog by clicking outside the alert area. Show activity on this post. When dialog closed, you can use dialog. setOnDismissListener at the following code with the usage of an updated dialog code.


2 Answers

Use an OnDismissListener.

There is a setOnDismissListener(...) method in the class Dialog

like image 137
Aleadam Avatar answered Oct 05 '22 09:10

Aleadam


Sure you can - check:

  public void onDismiss(DialogInterface dialogInterface)
  {
        //Fire event
  }
like image 20
Barmaley Avatar answered Oct 05 '22 09:10

Barmaley