I want to execute some function at specific hour picked by TimePicker.
I can use Handler like this:
Handler myHandler = new DoSomething();
Message m = new Message();
myHandler.sendMessageDelayed(m, delay);
class DoSomething extends Handler {
@Override
public void handleMessage(Message msg) {
MyObject o = (MyObject) msg.obj;
//do something here
}
}
And load the “delay” param with: picked_wanted_hour – current_hour
OR check for the current time at some interval and invoke the function when the time comes.
But, is there any handler-like object that can take a specific time and invoke the operation at that time?
Thanks in advance.
Why don’t you use handler itself? Just pass
timePickerTime - currentTimeas a delay.There’s also Timer with method
schedule(TimerTask task, Date when).