How to raise a toast in AsyncTask, I am prompted to used the Looper

前端 未结 6 1912
春和景丽
春和景丽 2020-11-29 08:20

I have tasks completed by AsyncTask in background. At some point I need to issue a Toast that something is completed.

I\'ve tried and I failed because Caused

6条回答
  •  没有蜡笔的小新
    2020-11-29 08:40

    If you want to display the Toast in doInBackground, you can use it in the OnPostExecute method of AsyncTask.

    protected void onPostExecute(String file_url) {    
       Toast.makeText(getApplicationContext(),"Your Message", Toast.LENGTH_LONG).show();
    
       pDialog.dismiss();//dismiss the progress dialouge
    }
    

提交回复
热议问题