Hi i am quite new to android.In my application I'm us开发者_StackOverflow社区ing an alert dialog and i want the alert dialog to be retained when the device is rotated from landscape to portrait and vice-versa.I'm using onRetainNonConfigurationInstance() to restore all other information but alert dialog is not getting retained.Any help is appreciated.
The simplest way is to add
android:configChanges="orientation"
to the activity declaration in manifest, like this:
<activity android:name=".MyActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name">
This is not recommended but works fine. Read Handling the Configuration Change Yourself for more information.
精彩评论