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. donut is coming but still no blluetooth for data/file transfer - bummer...

no need to say further...
--~--~---------~--~----~------------~-------~--~----~

2. Google speech recognition

Hi,

I use the Google speech recognition Intent for my application. I can
use the speech recognition in Maps or with the Google search Widget
with my HTC Magic (cupcake CRC1).

One of my user which has the same mobile and the same version of
Android doesn't have the speech recognition and thus can't use my
application.

Does someone know why?

Thanks in advance

(I've post first this message in the Android Discuss group but it
don't appears, maybe it was not in the good group, sorry if there a
duplicate)

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

3. Sending email with Apache commons

4. 1.6 SDK Arrow keys (dpad/trackball) dir not changing with orientation?

5. 3d Physics Engine?

6. Migration of iphone鈥檚 app lication to Android

7. Technology: parse + handling xml files