fatal exception in android Timer

前端 未结 4 1569
旧时难觅i
旧时难觅i 2021-01-28 06:27

in my android application i\'m using Timer schedule.but getting Timer-0 fatal exception as below.how can i remove it.i have also mentioned code below -

01-28 13:         


        
4条回答
  •  日久生厌
    2021-01-28 07:05

    use runOnUiThread for updating UI element from Timertask run Method as :

     myTimer.schedule(new TimerTask() {      
    
     @Override
     public void run() {
      Current_Activity.this.runOnUiThread(new Runnable() {
        public void run() {
            // update UI here
        }
     });
     }
    },0, 1000);
    

提交回复
热议问题