I'm working on a method in a service class in Android Studio..
I used Timer to re-execute the method every one minute.. but the seconds is matter in my case..
when the onStartCommand
lunched at for example 13:40:22, the forRoom1()
method we will execute and wait one minute so it will be re-executed at 13:41:22..
I want the forRoom1()
method to start its first execution at 13:40:00 so after waiting one minute it will re-executed at 13:41:00..
here is my onStartCommand code:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
forRoom1();
}
}, 0, 60 * 1000);
return START_STICKY;
}
whatever is the current time, the most important thing is to start is first execution at second 00 can you please help me with this?