On Fri, Sep 9, 2011 at 8:24 PM, Greg Donald <[email protected]> wrote:

> Also tried it without the dismissDialog() call in onDestroy().
>
> The exceptional condition is:
>
> 09-09 20:05:12.626: ERROR/AndroidRuntime(3831): Caused by:
> java.lang.IllegalArgumentException: no dialog with id 0 was ever shown
> via Activity#showDialog
>

With showDialog() and its brethren, the activity manages the dialog for you
on destroying and recreating the activity - conceptually it gets passed from
the original instance to the new instance. But your thread is still running
in the original instance, so when it tries to hide the dialog, the system
already took care of it, so boom.

Honestly, this doesn't seem like it should raise an exception - if you try
to dismiss a dialog that was never shown, oh well, don't do anything. But it
is what it is.

I ran into the exact same issue - my hacky fix was to keep a "am destroyed"
flag in the activity. In onDestroy set it to true then in your runnable
protect the call to dismiss with a check on that flag.

If the activity has already been destroyed, you don't have to dismiss it,
otherwise you do and safely can.


> At this point I'm going with
>
> setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
>


It's a sure thing.


It's not - again, you're just masking the problem and will run into it via
other means, though likely with much less likelihood.

Good luck to the next guy..  I can't make it work.


Come on! You can do it <http://www.youtube.com/watch?v=DMFg2aU3x4o>!

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to