UI, including dialogs, is fundamentally an asynchronous process served
by the same thread.

A show() on a dialog is a "delayed instruction" to tell the main
thread to show the dialog when it comes back around the loop to
process that message.  However if you follow the "show" with a
"dismiss" in the same thread then you cancel each other out (may be
with a bit of delay).

If you inject some processing between show and dismiss, as long as you
are on the same main thread of execution it is ineffective.

You should try to use an AsyncTask along with a progress dialog to
accomplish what you are looking for.

Or if you insist not to use the asynctask then you need to post
yourself a message (through a handler) after showing the dialog so
that you can pick up the processing and at the end ofthe processing
you can dismiss the dialog.

There are quite a few articles on the web on asynctask.

I have link below that is a bit more detailed and if you have patience
to read through that it could be helpful

http://www.satyakomatineni.com/item/3536


On Sat, May 28, 2011 at 10:00 AM, B Lyon <bradfl...@gmail.com> wrote:
> I've never used that one, but I'm wondering if the second ".show()" is
> necessary, and/or if it is somehow causing weirdness?  This person
> (http://www.helloandroid.com/tutorials/using-threads-and-progressdialog)
> didn't do that.
>
> On Sat, May 28, 2011 at 9:43 AM, EmilDiego <emildi...@gmail.com> wrote:
>> I have a function inside one of my activities that calculates some
>> statistics and takes a little time to generate a report.  I want to
>> display a progressDialog while this is going on to give the user some
>> feedback that something is happening while he is waiting.  The problem
>> I am having is that I can't get my progressDialog to display no matter
>> what I do.  Is there some obscure factoid that I am missing out on
>> here that is preventing this to work.  This problem is particularly
>> perplexing because I am using similar code elsewhere in the Activity
>> and that works ok.  Any ideas
>>
>>
>> Here is my code:
>>
>> //* ADD THE CODE FOR THE PROGRS DIALOG
>>                //* Start the progress dialog
>>                xReportProgress = ProgressDialog.show(this, "", "Preparing
>> Report.");
>>                xReportProgress.show();
>>
>>                switch(iReportFormat)
>>                {
>>                        case callLog.REPORT_FORMAT_CSV:
>>                                sReportOutput = this.createCSVReport();
>>                                break;
>>
>>                        case callLog.REPORT_FORMAT_XML:
>>                                sReportOutput = this.createXMLReport();
>>                                break;
>>
>>                        default:
>>                                
>> ed.app.commTracker.main.systemLog.logError("Invalid report
>> format.");
>>                                return;
>>
>>                }
>>
>>                //* Close the dialog so we can display the intent chooser
>>                xReportProgress.dismiss();
>>
>> --
>> 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+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
> --
> 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to