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. Hey Google, do this!

Here's an idea. Why don't you guys package the SDK documentation
(documentation.html & its associated directory tree)  into a SINGLE
html file for print.  I so much would like to print the whole darn
thing out so I can read on the subway.  Single page prints are just
too impactical.

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

2. WifiManager issues

Hello,

I'm having an issue with WifiManager on the G1.  I think the issue has
more to do with Intents, BroadcastReceivers, Activities, and other
things I'm unfamiliar with the language of.

1. I have a ListActivity derived class which is what loads on startup
of the app.
2. A class member is a WifiManager, which calls WifiManager.startScan
().
3. I've tried to create an intent, but onActivityResult is never
called:
  Intent mIntent = new Intent("android.net.wifi.SCAN_RESULTS");
  setResult(RESULT_OK, mIntent);
  //The result of startScan may be false if it won't run properly.
  // If it does, you want to execute the Intent so that there is a
response.
  if(mManager.startScan()){
        Log.i(this.toString(), "Scan started successfully.");
        //      startActivityForResult(mIntent, COMPLETED_SCAN);
  }

4. I set up a BroadcastReceiver to handle the
'android.net.wifi.SCAN_RESULTS' action, and the onReceive handler is
called.  The problem here is that onReceive is a function of a
BroadcastReciever derived class.

Which way is the proper way to handle actions?  How can I read in
ScanResults asynchronously?  If I use the BroadcastReceiver, how can I
send data back to the ListActivity so that the data can be displayed?
Am I approaching this properly?

Thanks,
Benry

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

3. Extending call logs?

4. Google Market Download Numbers

5. is there a way to disable the GSM(phone) part of the phone only?

6. WifiManager

7. PhoneStateListener not being called back