Problem with Toast in AsyncTask method call

前端 未结 4 993
故里飘歌
故里飘歌 2020-12-10 08:54

Hey Everybody,
I have an AsyncTask that posts some data to a server. It does this by calling a static method that I wrote from doInBackground. When I run the AsyncTask,

4条回答
  •  萌比男神i
    2020-12-10 09:40

    you can Toast inside doInBackground

    use this code

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

提交回复
热议问题