I am creating an application in which an alert dialog box pops up when i click on a button.Now when the phone is rotated this view gets disappears.Can anyone help me to retain this alert view even if phone is rotated?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The matter is that the system destroys the activity when a change in the configuration occurs.
See http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges
You have to add this to the activity declaration in the manifest:
android:configChanges=”orientation”
so it looks like
So putting that in the configuration file avoids the system to destroy your activity. Instead it invokes the onConfigurationChanged(Configuration) method.
Or you can “force” your activity to be fixed on landscape or portrait mode and then the alertview will be retained but the view will be fixed whether the phone rotates or not .
It can be made by adding this to your manifest file (in your activity) :
android:screenOrientation=”portrait” or android:screenOrientation=”landscape”