[android-developers] trying to show a progressdialog in a lengthy task

2010-02-17 Thread guich
Hi,

When i first launch my main intent, i check if the application was
updated and, if yes, i decompress some asset files. This task can take
up to 15 seconds (to decompress a 6MB zip file).

So, i was trying to show a ProgressDialog to the user. However,
nothing in hell makes the dialog appear.

The lengthy method is called from onCreate. I already tried to put it
in onStart, but same thing. I also tried to run it in the ui thread,
same thing: no dialog appears, even if isShowing returns true.

This is the code:

showProgressDialog
while (...)
   // a 15-second task
nowQuit();

What can i do to make the dialog really show up on screen?

thanks

   guich

-- 
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


Re: [android-developers] trying to show a progressdialog in a lengthy task

2010-02-17 Thread Mark Murphy
guich wrote:
 Hi,
 
 When i first launch my main intent, i check if the application was
 updated and, if yes, i decompress some asset files. This task can take
 up to 15 seconds (to decompress a 6MB zip file).
 
 So, i was trying to show a ProgressDialog to the user. However,
 nothing in hell makes the dialog appear.
 
 The lengthy method is called from onCreate.

Don't do that. That is on the main application thread.

 I already tried to put it
 in onStart, but same thing.

Don't do that. That is on the main application thread.

 I also tried to run it in the ui thread,
 same thing: no dialog appears, even if isShowing returns true.

Don't do that. That is on the main application thread.

 This is the code:
 
 showProgressDialog
 while (...)
// a 15-second task
 nowQuit();
 
 What can i do to make the dialog really show up on screen?

Get your long-running work off the main application thread. Use an
AsyncTask or an IntentService.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 14-18 June 2010: http://bignerdranch.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