1:handler实现定时器的功能
Handler handler=new Handler();
//立即执行Runnable对象
public final boolean post(Runnable r);
//在指定时间uptimeMillis 后执行Runnable对象
public final boolean postAtTime(Runnable r,long uptimeMillis);
//在指定的时间间隔delayMillis 执行Runnable对象
public final boolean postDelayed(Runnable r,long delayMillis);
在指定时间
handler.postAtTime(new Runnable() {
public void run() {
// TODO Auto-generated method stub
ToastUtils.show(mContext, "数据已备份");
}
}, android.os.SystemClock.uptimeMillis()+2000);
时间间隔
handler.postDelayed(this, 2000);
public void run() {
// TODO Auto-generated method stub
Log.e("+++++++++>", "数据已备份");
handler.postDelayed(this,2000);
}