Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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?

like image 837
Albert Avatar asked Aug 28 '16 22:08

Albert


1 Answers

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.

like image 139
CommonsWare Avatar answered Nov 14 '22 23:11

CommonsWare