Changes between Version 16 and Version 17 of question_new


Ignore:
Timestamp:
09/03/2014 11:12:29 AM (12 years ago)
Author:
liaojiaohe
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • question_new

    v16 v17  
    5555 
    5656 
     57---- 
     58 
     59== Q: 延时执行方法== 
     60A:  
     61一:开启新线程 (不建议)[[BR]] 
     62 
     63二:利用定时器(推荐) [[BR]] 
     64 
     65{{{ 
     66TimerTask task = new TimerTask(){    
     67    public void run(){    
     68    //execute the task 
     69    }    
     70};    
     71Timer timer = new Timer(); 
     72timer.schedule(task, delay); 
     73}}} 
     74  
     75 
     76三:使用handler的postDelayed方法[[BR]] http://blog.csdn.net/xiabo851205/article/details/7991529 (感觉做间隔调用挺方便)[[BR]] 
     77 
     78{{{ 
     79new Handler().postDelayed(new Runnable(){    
     80    public void run() {    
     81    //execute the task    
     82    }    
     83 }, delay);   
     84}}} 
     85  
     86四:利用AlarmManager,特点时刻广播指定意图能实现,一般的简单任务不这么做。[[BR]] 
     87