Hi,
I want to start a task at 9 am (exact time) at every day by using this library. Can you help me by,
What is the best ( periodic or exact that is scheduled again) to start in time alarm?
Then What would be the time calculation. Please give an example by my time like 9 am for each day.
Thanks,
Ruhul
A sample is here.
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int minutesToStart = 00;
int hoursToStart = 9;
long startMs = TimeUnit.MINUTES.toMillis((minutesToStart - (minute))) + TimeUnit.HOURS.toMillis(((hoursToStart - hour) % 24));
if (startMs < 0) {
Log.d(TAG, "next scheduling in a day...");
startMs += TimeUnit.DAYS.toMillis(1);
}
new JobRequest.Builder(DemoSyncJob.TAG)
.setExact(startMs)
.setPersisted(true)
.setUpdateCurrent(true)
.build()
.schedule();
Is it ok for firing alarm at 9am and every day ??
it is not worked for me :(
I gave you a sample and you should be able to do the rest. If not, please ask these questions at a better place like Stackoverflow.