On Thu, Sep 8, 2011 at 2:14 PM, Greg Donald <[email protected]> wrote:

> How can I keep my dismiss() calls from blowing up?


Keep a class-level reference to the dialog and dismiss it if you're being
destroyed. Or use showDialog() / dismissDialog().

The issue (I ran into this):
1 - You show your dialog in Activity instance A.
2 - You rotate device while it's still showing.
3 - Background thread is still running in Activity instance A which is now
being destroyed.
4 - Background thread finally finishes and tries to dismiss a dialog that is
no longer attached to the original Activity instance A.
5 - Boom.


>  Why doesn't try/catch work?


I *think* because dismiss is asynchronous - calling dismiss just puts the
dialog in the queue for cleanup. I think.

-------------------------------------------------------------------------------------------------
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