You can’t do UI
stuff in doInBackground()
. Hence, you can’t display a Toast
there. You need to move this to onPostExecute()
or somewhere else. Possibly onProgressUpdate()
You could call publishProgress(results)
and show the Toast
in onProgressUpdate()
or return results
to onPostExecute()
and display it there. You also have the option of sending the data back to an Activity
method
AsyncTask