Quirky behavior when rotating screen in API Demos sample, Progress dialog

by blindfold » Thu, 04 Sep 2008 23:53:04 GMT


Sponsored Links
 Yes the dialog should remain visible but be automatically dismissed
after the progress bar fills up, just like when one does not change
the screen orientation. It is the restarting of the application (I
noticed that in my own app) that apparently gets the running progress
dialog handling messed up in ways that are not obvious to circumvent.




--~--~---------~--~----~------------~-------~--~----~



Quirky behavior when rotating screen in API Demos sample, Progress dialog

by blindfold » Fri, 05 Sep 2008 00:58:38 GMT


 For my own use I do not care if the progress dialog continues from
where it was or starts all over, so I need no save/restore of its
state. However, the fact that the progress bar does not start at all
after changing screen orientation suggests a bug. The impression I got
is that the progress dialog upon dismiss does not get cleaned up
before the activity restarts and attempts (and fails due to a conflict
with the lingering previous progress dialog) to recreate that same
progress dialog. As an application developer I have no control over
the asynchronous dismiss handling, and I cannot see what happens under
the hood that makes it fail, so the above is just my conjecture.




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Quirky behavior when rotating screen in API Demos sample, Progress dialog

by blindfold » Fri, 05 Sep 2008 04:31:22 GMT


 Adding one debug output line to AlertDialogSamples.java to get

   super.handleMessage(msg);
   Log.i("OIC", "mProgress = " + mProgress);

shows that the handler keeps incrementing mProgress under the
condition that I mentioned, but without dismissing the dialog when
mProgress reaches 100 (and indeed stops counting). I do not see how
adding another trigger message could help with this.

Or more explicitly,

        mProgressHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                Log.i("OIC", "mProgress = " + mProgress);
                if (mProgress >= MAX_PROGRESS) {
                    Log.i("OIC", "This should dismiss me, but...");
                    mProgressDialog.dismiss();
                } else {
                    mProgress++;
                    mProgressDialog.incrementProgressBy(1);
                    mProgressHandler.sendEmptyMessageDelayed(0, 100);
                }
            }
        };

gives

...
09-04 20:11:35.021: INFO/OIC(248): mProgress = 97
09-04 20:11:35.127: INFO/OIC(248): mProgress = 98
09-04 20:11:35.233: INFO/OIC(248): mProgress = 99
09-04 20:11:35.332: INFO/OIC(248): mProgress = 100
09-04 20:11:35.332: INFO/OIC(248): This should dismiss me, but...

the dialog remains on the screen if the screen orientation was changed
during the count.

Or if I add

    @Override
    protected void onPause() {
       super.onPause();
       Log.i("OIC", "This too should dismiss me, but...");
       mProgressDialog.dismiss();
    }

then I do get the "This too should dismiss me, but..." upon changing
the screen orientation somewhere during the count (and the count
continues), but the progress dialog still does not go away.





--~--~---------~--~----~------------~-------~--~----~



Quirky behavior when rotating screen in API Demos sample, Progress dialog

by blindfold » Fri, 05 Sep 2008 05:45:52 GMT


 Yes we agree now that it is not a trigger message problem.


So what method is there to kill or stop the handler? I could not find
it.

Moreover, killing the old handler will not solve the problem with the
out-of-control new progress dialog that Android instantiates upon a
screen orientation change. I would have to know its handle to dismiss
it, but I cannot know its handle because I did not instantiate the new
progress dialog myself, right?

In other words, is there finally a fix for the problem? How do I
dismiss that new ProgressDialog?

Thanks




--~--~---------~--~----~------------~-------~--~----~



Quirky behavior when rotating screen in API Demos sample, Progress dialog

by blindfold » Sun, 07 Sep 2008 04:16:21 GMT


 I finally obtained a workaround/fix, as described in

 http://code.google.com/p/android/issues/detail?id=857 

--~--~---------~--~----~------------~-------~--~----~



Quirky behavior when rotating screen in API Demos sample, Progress dialog

by hackbod » Sun, 07 Sep 2008 14:29:53 GMT


 


Sure you did.  Please read:
 http://code.google.com/android/reference/android/app/Activity.html #ConfigurationChanges

What happens when an orientation change occurs is that the current
activity is destroyed, and a new one created.  So if you have bugs in
how you handle being destroyed (not correctly closing dialogs,
stopping message pumps) or in how it is re-created from its previously
saved state (not retrieving the state and performing its
initialization based on that), then you will have bugs during an
orientation change.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. How to customize android button's look and feel

Hi,

Can you please tell me how can I customize android button's look and feel?
e.g. by default, it uses a grey round rectangle as the border and it
has 'orange' background when it has focus.
Can you please tell me how can i config that in my application?

Thank you.

--~--~---------~--~----~------------~-------~--~----~

2. Toggle Button example

Hi,

Can you please tell me where I can find example in ToggleButton?

http://code.google.com/android/reference/android/widget/ToggleButton.html

Thank you.

--~--~---------~--~----~------------~-------~--~----~

3. Cannot setup "Setting up Eclipse" before "Installing the Eclipse Plugin (ADT)"

4. wireless tools

5. build_server.sh failed to build ADT 0.9.0 on Mac OS

6. Preferences not saved *sometimes*

7. G1 Fax software