Android Save instance state for dialogs?

I wonder how to implement this correctly? Can someone find out if my decision is right?

So:

  • Action created
  • The user presses the button and the dialogue starts (dialogue, not dialogue style)
  • The user opens the keyboard.
  • We have onSaveInstanceState, where we save that our dialog has been opened, and all relevant dialog entries
  • we have onRestoreInstanceState, and here we check if the dialog was shown, re-create the dialog with the appropriate input.

Is this the right approach? or is smth. what Android does and I do some redundant actions.

thanks

+4
source share
2 answers

Yes, this is the right way to do this. Dialog does not extend Activity s, but they work very similarly, and you just described the correct "stream" for saving / restoring states for.

+2
source

Try commenting on your onRestoreInstanceState () and see if the application loads the information you expected to save.

I hope this helps! Greetings.

+1
source

All Articles