I\'m migrating my dialogs, currently using Activity.showDialog(DIALOG_ID);
, to use the DialogFragment
system as discussed in the android reference.
Another way is that you can stop the activity getting recreated. You have to tell Android that you'll handle the orientation change yourself and android won't recreate your activity. You need to add this for your activity to your manifest file:
android:configChanges="keyboardHidden|orientation"
If not this, then you can use standard onSaveInstanceState()
to save your state and recover using savedInstanceState
as recommended by Google.
Here's Google's official guide for it: http://developer.android.com/guide/components/activities.html#Lifecycle
Go through it if you haven't already. It'll really help you in android development.