Trying to fix NetworkOnMainThreadException but gives Toast error

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)