Thursday, September 8, 2011

Re: [android-developers] Dialog dismiss()

Actually, don't use a ProgressDialog, use Activity.showDialog()
instead. This handles device orientation.

On Thu, Sep 8, 2011 at 2:41 PM, Miguel Morales <therevoltingx@gmail.com> wrote:
> The problem is that you are attempting to update the UI in a foreign thread.
> This line: progressDialog.dismiss();
>
> You seem to be using a handler, so just change it to:
> handler.postRunnable(new Runnable() {
>    @Override
>    public void run() {
>        progressDialog.dismiss();
>    });
>
> Don't ever touch the UI outside of the UI thread.
>
> To handle rotation, save a static instance of your activity in your
> onCreate() method and remove it on onDestroy();
> So, something like:
>
> static MyActivity mStaticSelf = null;
>
> onCreate() {
>    mStaticSelf = this;
> }
>
> Then change your handler code to:
> @Override
>    public void run() {
>        mStaticSelf.progressDialog.dismiss();
>    });
>
> On Thu, Sep 8, 2011 at 2:30 PM, Greg Donald <gdonald@gmail.com> wrote:
>> On Thu, Sep 8, 2011 at 2:29 PM, TreKing <trekingapp@gmail.com> wrote:
>>> On Thu, Sep 8, 2011 at 2:14 PM, Greg Donald <gdonald@gmail.com> 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.
>>
>> Well, I just have the one instance I reuse everywhere already.  And if
>> what you said below about it being asynchronous is true, then my other
>> checks to see if it's still around could still pass later.
>>
>> I don't get why if( this != null ) evaluates to true when the stack
>> trace seems to imply the Activity is gone already.
>>
>>> 2 - You rotate device while it's still showing.
>>
>> Exactly what I'm hearing.  Rotate, 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.
>>
>> Geez..  I'm thinking I might just lock it in to landscape mode and
>> forgo the grief.
>>
>>
>> --
>> Greg Donald
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscribe@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>
> --
> ~ Jeremiah:9:23-24
> Android 2D MMORPG: http://solrpg.com/http://www.youtube.com/user/revoltingx
>

--
~ Jeremiah:9:23-24
Android 2D MMORPG: http://solrpg.com/http://www.youtube.com/user/revoltingx

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

No comments:

Post a Comment