Why dismissDialog method not working properly?
I am using the showDialog and dismissDialog methods to show progress dialogs in my app. Moved from creating the dialog and calling show() on it to using this in order to save state when changing orientation.
But when I change the orientation from portrait->landscape->portrait, the dismissDialog no longer dismisses the dialog. The dialog stay there all the time and I need to press the 开发者_如何转开发back button for it to disappear.
Any reason why it would behave that way?
Thanks
Android destroys the activity if any change happens in the configuration. See http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges.
Put following code in your manifest file. This will not destroy the activity and instead will call the onConfigurationChanged()
method
<activity android:label="@string/app_name" android:configChanges="orientation"
android:name=".package">
Change your progress dialog to a global definition, and make it static, that should be enough.
精彩评论