实现思路:使用handler延迟开启一个线程,在线程中延迟开启自己和执行相应的逻辑。
private static final int LENGTH_OF_TIMING = 15000;
private static Runnable runnable = new Runnable() {
@Override
public void run() {
handler.postDelayed(this, LENGTH_OF_TIMING);
//执行相应的逻辑
TVAppUtil.updateReportData();
}
};
private static Handler handler = new Handler();
//调用
handler.postDelayed(runnable, LENGTH_OF_TIMING);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
//doSomething...
}
}, 2000,2000);
如果对您有用的话赞一下呗!谢谢啦!