我想在用户设置的时间间隔内显示警告框并显示警告1分钟。如果在1分钟内未执行任何操作,则发送消息并拨打特定号码。所以请帮助解决我的问题。任何人都可以帮助我......
答案 0 :(得分:2)
Timer myTimer;
myTimer = new Timer();
myTimer.schedule(new TimerTask() {
@Override
public void run() {
TimerMethod();
}
}, 0, 10000);
}
}
private void TimerMethod()
{
//This method is called directly by the timer
//and runs in the same thread as the timer.
//We call the method that will work with the UI
//through the runOnUiThread method.
this.runOnUiThread(Timer_Tick);
}
private Runnable Timer_Tick = new Runnable() {
public void run() {
//This method runs in the same thread as the UI.
//Do something to the UI thread here
}
};
试一试。 如果有效,请告诉我。