Some notes on android dialogs

satya - 3/7/2013 4:15:28 PM

Here are some notes on fragment dialogs

Here are some notes on fragment dialogs

This is not overly useful for simple dialogs.

satya - 3/7/2013 4:15:40 PM

putting up a simple android alert dialog

putting up a simple android alert dialog

Search for: putting up a simple android alert dialog

satya - 3/7/2013 4:20:22 PM

You can do this


public void alert(String title, String message)
{
   AlertDialog alertDialog = new AlertDialog.Builder(this).create();
   alertDialog.setTitle(title);
   alertDialog.setMessage(message);
   alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
      }
   });
   alertDialog.show();      
}

satya - 8/17/2013 4:00:15 PM

Recommendation is to wrap dialogs in a dialog fragment...

and use the dialog fragment methods to show and respond to the dialog. This approach may replace the older method of regiestering dialog ids for the sake of recreating them during configuration changes.

satya - 8/17/2013 4:16:05 PM

An alert dialog like the above will not be flipped

In other words the activity will not recreate the dialog if the activity is flipped.

satya - 8/17/2013 4:48:37 PM

Remember! there are three kinds of dialogs in Android


Simple ones that dont' track state

//old kind
Managed dialogs: activites manage state for dialogs

//new kind
Fragment Dialogs: Fragments contain and manage state for dialogs

satya - 8/17/2013 5:23:53 PM

All of the APIs around managed dialogs are deprecated.

This leaves only the dialog fragments as the approved way to show dialogs.

satya - 10/28/2013 10:30:35 AM

Dialogs and setCancelable

Dialogs and setCancelable

Search for: Dialogs and setCancelable

satya - 10/28/2013 10:32:35 AM

In android you can prevent a dialog from closing on back

In android you can prevent a dialog from closing on back

Search for: In android you can prevent a dialog from closing on back

by default the setcancelable is true.

You can set this to false to prevent a dialog from closing on back. This may be useful if you have an asynctask that you want to complete and want to give a hint to the user.

The home button seem to work fine taking you to the home screen.

satya - 10/28/2013 2:12:12 PM

You cannot call a dismiss on a dialog when the activity is stopped

for example, if you go home while a dialog is being displayed, and an asynctask has finished and wants to close its dialog, then the state of the dialog won't allow its dismissal!

So from a UI perspective there are certain things you cannot do when the UI has stopped

satya - 11/1/2013 4:43:24 PM

In Android does dismissing a dialog fragment remove the fragment?

In Android does dismissing a dialog fragment remove the fragment?

Search for: In Android does dismissing a dialog fragment remove the fragment?