Dialog being dismissed when activity restarts?

Your activity is restarted when you rotate the device. You can stop this by adding this to your application part in the manifest: android:configChanges="orientation|keyboard.

I want to keep the dialog shown when the user returns. – Flávio Faria Mar 16 at 20:12 2 You should use the various functions of the application lifecycle (onPause, onDestroy, etc) to set a boolean, and when the onReturn etc is called, check for this boolean and restart the dialog. – Nanne Mar 16 at 20:13 This was the solution I thought about, but I didn't like it very much.

I thought Android had a better way to deal with it. – Flávio Faria Mar 16 at 20:17 1 Well, this is quite a good way. You have a certain state, and you want to save that state, and return to it when you start again.

It is some extra work for the developer, but it means lots of good things for the user. – Nanne Mar 16 at 20:18 OK. I'll accept it as an answer.

– Flávio Faria Mar 16 at 20:24.

Flavio, You can prevent your Activity from being recreated on orientation changes by adding the following in your AndroidManifest. Xml: Then you need to override the following method in your code: @Override public void onConfigurationChanged(Configuration newConfig) { super. OnConfigurationChanged(newConfig); }.

Flavio: I am unable to recreate the problematic behavior with alertDialogs or custom dialogs on orientation change. Are you using onCreateDialog and showDialog(int id)? According to the docs "the dialog will be automatically saved and restored if you use showDialog.

This is my experience. It is even possible to create an XML layout with an editText widget, inflate the layout, and the state in the editText will be automagically saved on orientation change. AlertDialog.

Builder builder= new AlertDialog. Builder(this); LayoutInflater inflater= getLayoutInflater(); final View myView= inflater. Inflate(R.layout.

Alert_dialog_text_entry, null); builder. SetTitle("About"); builder. SetMessage(alertMessage+"Version: "+versionName); builder.

SetView(myView); AlertDialog alert= builder.create(); I have code here and here with screen captures that demonstrates the persistence of the alertDialog and custom dialog on orientation change.

Flavio: I am unable to recreate the problematic behavior with alertDialogs or custom dialogs on orientation change. Are you using onCreateDialog and showDialog(int id)? According to the docs "the dialog will be automatically saved and restored if you use showDialog.

This is my experience. It is even possible to create an XML layout with an editText widget, inflate the layout, and the state in the editText will be automagically saved on orientation change.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions