- new Thread(new Runnable(){
- public void run(){
- Thread.sleep(XXXX);
- handler.sendMessage();----告訴主線程執行任務
- }
- }).start
② 利用定時器
- TimerTask task = new TimerTask(){
- public void run(){
- //execute the task
- }
- };
- Timer timer = new Timer();
timer.schedule(task, delay);
③
- new Handler().postDelayed(new Runnable(){
- public void run() {
- //execute the task
- }
- }, delay);