I have read about Job Scheduler on Developer page and http://www.vogella.com/tutorials/AndroidTaskScheduling/article.html After reading about it, I am confused and unable to understand on how to use Job Scheduler. Presently I use Alarm Manager, to schedule a task to run evry 6 hours. I am wondering if the same task can be done using Job Scheduler. If yes, how can that be done?how?
Asked
Active
Viewed 149 times
0
-
1"I am confused and unable to understand on how to use Job Scheduler" -- we cannot help you with that, if you do not explain **specifically** what you do not understand. "I am wondering if the same task can be done using Job Scheduler" -- probably. It would depend a bit on the nature of the task, but most things that can be triggered via `AlarmManager` can be triggered via `JobScheduler`. – CommonsWare Apr 11 '17 at 12:51
-
Actually i have one task which i have to do in every 6 hrs and i use alarm manager for this to detect that when i schedule my task like 12am then 6am like. So Is it possible to do this task with JobScheduler instead of alarm manager – Bhanu Sharma Apr 11 '17 at 13:11
-
1You can use `JobScheduler` to schedule periodic jobs and ask for an every-six-hours period. You cannot force the precise timing of the job (e.g., exactly at 6am), but with Doze mode/app standby on Android 6.0+, you cannot do that with alarms either. – CommonsWare Apr 11 '17 at 13:14
-
Yes i know in Android 6.0 if my phone is in sleep or ideal mode then Alarm Manager is not working – Bhanu Sharma Apr 11 '17 at 13:16
-
builder.setMinimumLatency(5 * 1000); // wait at least builder.setOverrideDeadline(50 * 1000); Is this funcation is using for timing and repeat – Bhanu Sharma Apr 11 '17 at 13:22
-
[Use `setPeriodic()`](https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#setPeriodic(long)) for periodic jobs. – CommonsWare Apr 11 '17 at 13:24
-
Can't call setOverrideDeadline() on a periodic job CRESH – Bhanu Sharma Apr 11 '17 at 13:28
-
1Since [`setOverrideDeadline()` is documented to crash when you try using it with `setPeriodic()`](https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#setOverrideDeadline(long)), this is not surprising. – CommonsWare Apr 11 '17 at 13:33
-
one more thing if Doze mode/app standby in OS 6 then how it is reacting like in on 6am my device is in sleep mode and 7am i unlock then how it behave – Bhanu Sharma Apr 11 '17 at 13:35
-
setPeriodic is not working for me once it call it will never call – Bhanu Sharma Apr 12 '17 at 07:15