Using toast inside timertask

前端 未结 4 641
迷失自我
迷失自我 2021-01-20 08:35

Found someone has similar issue online here.

This doesn\'t work:

Timer t = new Timer(false);
t.schedule(new TimerTask() {
@Override
public void run()         


        
4条回答
  •  暖寄归人
    2021-01-20 09:10

    Everytime you start an application, it starts on the UI Thread (also called the Main Thread).

    Whenever you create a new Thread, or Timer, or AsyncTask, by definition, they're creating new Threads. Threads that aren't the main thread simply don't have permission to modify the UI.

提交回复
热议问题