How to show toast in AsyncTask in doInBackground

后端 未结 9 768
灰色年华
灰色年华 2020-11-27 23:01

In one of my activities I\'m using AsyncTask. In doInBackground() I\'m making calls to various methods. In one of these methods I\'m getting an exc

9条回答
  •  无人及你
    2020-11-27 23:30

    You could wrap the Toast in runOnUIThread() but this isn't the best solution.
    You should set a boolean flag in the catch block when an error occurs, then display an appropriate Toast in onProgressUpdate(), onPostExecute(), or any of the other methods with UI access whenever the flag is true.

提交回复
热议问题