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

前端 未结 6 1899
春和景丽
春和景丽 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:45

    you can Toast inside doInBackground

    add this code where you want to Toast appear

    runOnUiThread(new Runnable() {
    public void run() {
    
        Toast.makeText(.this, "Cool Ha?", Toast.LENGTH_SHORT).show();
        }
    });
    

提交回复
热议问题