Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

alert dialog inside asynctask in android

I need to show the Alertdialog inside Asynctaskin android , but it won`t show in throws exception.

05-13 14:59:35.522: WARN/System.err(1179): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

Thanks.

like image 631
Karthi Avatar asked May 13 '11 09:05

Karthi


3 Answers

It isn't possible to manipulate the UI from the background thread. Use handler or the onPre/Post methods of the AsyncTask for that.

like image 151
Stephan Avatar answered Nov 10 '22 21:11

Stephan


Show the dialog in onPostExecute() method rather than doInBackground.

Hope that helps

like image 37
Omar Rehman Avatar answered Nov 10 '22 22:11

Omar Rehman


I think this might be your problem -- you can't show a dialog from inside doInBackground.

like image 22
Ben Williams Avatar answered Nov 10 '22 22:11

Ben Williams