Can't Create Handler Inside Thread That Has Not Called Looper.prepare() In Android
I am getting can't create handler inside thread in asynchronous background task. Below is my code. I made the necessary modifications to progress bar after searching in google but
Solution 1:
You can not update the UI thread(Main Thread) from another thread.. If you want to do it
1) Return your response String from doInbackground, and update the UI in PostExecute()
2)Otherwise you can wrap the Toast Message in runonUiThread(){}
3) Use Handler to update the UI from another thread.
Solution 2:
You cannot use Toast in the do in background operation because you need the UIThread to show them. Instean of doing that as you did. Use a variable an save it for different states.
In onPostExecute check the variable and show the corresponding Toast.
Hope it helps.
Post a Comment for "Can't Create Handler Inside Thread That Has Not Called Looper.prepare() In Android"