Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android. Save Instance State for Dialogs?

I wonder what is the right way to implement this? Could anybody advice whether my solution is correct?

So:

  1. Activity is created
  2. User clicks on button and dialog is launched (Dialog, not dialog styled activity)
  3. User opens keyboard
  4. we have onSaveInstanceState called where we save that our dialog was opened and all respective dialog input
  5. we have onRestoreInstanceState and here we check whether dialog was shown, recreate the dialog with respective input.

Is it the right approach? or there is smth. that is done by Android and I am doing some redundant actions.

Thanks

like image 417
Lyubomyr Dutko Avatar asked Sep 24 '09 17:09

Lyubomyr Dutko


1 Answers

Yes, that is the right way to do it. Dialogs don't extend Activitys, but they work very similarly and you've just described exactly the correct "flow" for saving/restoring states for either.

like image 200
Jeremy Logan Avatar answered Oct 04 '22 04:10

Jeremy Logan