1. Open a new thread
new Thread(new Runnable(){
public void run(){
Thread.sleep(XXXX);
handler.sendMessage(); //Tell the main thread to perform the task
}
}).start
new Thread(new Runnable(){
public void run(){
Thread.sleep(XXXX);
handler.sendMessage();---- tell the main thread to perform the task
}
}).start
2. Use the timer
TimerTask task = new TimerTask(){
public void run(){
//execute the task
}
};
Timer timer = new Timer ();
timer.schedule(task, delay);
、 、 Handler + postDelayed
new Handler().postDelayed(new Runnable(){
public void run() {
//execute the task
}
}, delay);
4. Using AlarmManager, the specified intention can be achieved by broadcasting the feature at all times, but not for general simple tasks.