Albert Albert - 3 months ago 15
Android Question

Make JobScheduler and JobInfo.Builder run at a specific and exact time?

I am trying to create an app where I send notifications at a specific time. I was looking at the JobScheduler API with the JobInfo.Builder but when I looked at this page:

https://developer.android.com/reference/android/app/job/JobInfo.Builder.html

I see that the setPeriodic method says:


Specify that this job should recur with the provided interval, not
more than once per period. You have no control over when within this
interval this job will be executed


So it seems like this method will randomly do the task within the set time.

How can I use the JobScheduler API to set a task to happen at an exact time?

Answer

How can I use the JobScheduler API to set a task to happen at an exact time?

You don't. JobScheduler is specifically designed for inexact timing, so it can combine jobs from multiple apps, to try to reduce power consumption.

Your best option will be AlarmManager.

Comments