[android-beginners] ProgressDialog Handling

2010-07-24 Thread NIK
I came across a problem with the ProgressDialog.

I am using a ProgressDialog and a Thread for some networking stuff. I
want the ProgressDialog to be dismissed when the Thread finishes its
work. I am using a Handler to dismiss the ProgressDialog but i don't
know how to continue my
main program flow after the progress dialog. I tried to use a while
loop that called a method from the Thread indicating when the
networking staff was over, but then the ProgressDialog didn't show
until the Thread completed its work.

My code looks like this.

net = new Thread(this.handler);
ProgressDialog.show(this, Title, Message);
while(!net.getResult()){
//Wait
}
//Continue the normal program flow


The only solution that i can think of is to create a method for the
program flow after the ProgressDialog and call that method from the
handler class.

Any ideas on that?

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] ProgressDialog Handling

2010-07-24 Thread TreKing
On Sat, Jul 24, 2010 at 7:11 PM, NIK nikolaos.katsa...@gmail.com wrote:

 I am using a Handler to dismiss the ProgressDialog but i don't know how to
 continue my
 main program flow after the progress dialog.


You want to do something after the thread is done ... so at the end of the
thread dismiss the dialog and start the new logic flow.


 I tried to use a while loop that called a method from the Thread indicating
 when the networking staff was over, but then the ProgressDialog didn't
 show until the Thread completed its work.


Well yeah, you're blocking the UI thread which is responsible for showing
the ProgressDialog. If you don't let it continue it will never get to show
the dialog. Never block the UI thread.


 The only solution that i can think of is to create a method for the program
 flow after the ProgressDialog and call that method from the handler class.


Precisely.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en