• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Cannot get ProgressDialog to display in Thread

RazzleFnDazzle

Well-Known Member
Well I've seen a wide variety of failures while trying to get this to work. I have a thread that is started via an Activity. The thread needs to create/display progress dialogs and dismiss them.

When I tried to directly display the ProgressDialog I got an error that my Looper wasn't prepared. I looked up with a Looper was an implemented it. However, I had to call Looper.loop for the progress dialog to show up. After it showed up the application froze on that point never to continue past the Looper.loop call.

I couldn't get it to work so looked for a whole new way using a HandlerThread and a Handler. I create a HandlerThread and start it. I get the looper from the thread and create a Handler with it. My ProgressDialog or Toasts won't show up at all.

Is there an easier way to go about doing this?
 
First of all, all UI stuff must be handled by the UI (main) thread in Android! That's the main reason you need all the handlers and stuff...

The only other way to do it is by implementing a AsyncTask, that works like a Thread, but handles the communication with the UI thread to make it all happen...

You can look into it here:

AsyncTask | Android Developers
 
First of all, all UI stuff must be handled by the UI (main) thread in Android! That's the main reason you need all the handlers and stuff...

The only other way to do it is by implementing a AsyncTask, that works like a Thread, but handles the communication with the UI thread to make it all happen...

You can look into it here:

AsyncTask | Android Developers


Okay. I was thinking I needed to do that, but I wasn't sure. I gave it a shot, but I had the Thread already written. I'll have to refactor it out just for the dialog! I was afraid of that! Thank you.
 
Okay for anyone who is looking for this same issue I solve my problem by simply initializing my Handler.Callback inside the actually activity and passing it to the thread.
 
Back
Top Bottom