Reputation: 426
I have a Dialog with a couple of buttons and a spinner that seems to work fine except my app crashes under the following circumstances: 1. start activity 2. show dialog with Activity::showDialog (gets created in onCreateDialog) 3. click on the spinner so that it shows the list 4. spinner puts up an AlertDialog 5. rotate the device 6. crash with IllegalArgumentException
I can see that the Activity has gone away and also that my Dialog has gone away but the AlertDialog put up by the Spinner remains. I would just dismiss the Spinner AlertDialog but it is a private member of the Spinner class (I checked the Android source code) so there is no way to access it.
If you move the Spinner to the Activity you get: 1. start activity 2. click on spinner so that it shows the list 3. spinner puts up an AlertDialog 4. rotate the device 5. spinner AlertDialog disappears 6. activity is shown rotated
I can only conclude that either: 1. you are simply not supposed to put a spinner on an Dialog (or AlertDialog), or 2. there is a bug in Dialog or Activity
Does anyone has any wisdom on this issue?
Upvotes: 2
Views: 914
Reputation: 5071
I had the same issue with PopupWindow. The solution is to call
popup.dismiss()
in the onDestroy() method.
Upvotes: 0
Reputation: 39406
In the manifest, add this to the declaration of your activity:
android:configChanges="orientation"
Upvotes: 1