5

Short version: Alarm Managers no longer work in the background in Android 8 (Oreo), Android people are saying to use Job Scheduler as the alternative, but the job scheduler doesn't allow specific times of the day like Alarm Manager did so well.

Longer version: I have a "reminder" notification that goes off at a specific time of day set by the user. Up to this point, I've used an alarm manager to post the notification at the set time. This sends the user a notification to the user even if the app is in the background. But in Android Oreo / 8.0, this isn't allowed anymore. Most background services, receivers, etc. are fairly limited. I've set up a job scheduler, but doesn't allow for an exact time. Periodic settings in the job scheduler cannot be set ahead to a specific time. So despite Android's claims that job scheduler is the intended replacement for alarm manager, it doesn't seem to do one of the key things people use it for, setting at a specific time of the day. Does anyone know of a way to do this in Android Oreo in a way that it works even when the app is in the background?

I've tried sync adapters (need the alarm manager for that too!), handlers (nothing for a specific time), playing around with the different settings for the job service (periodic, minimumLatency, etc.), resetting the notification after the last one finished (can't do that in the background either!), and still haven't found a valid solution.

Is there anything that works like the job scheduler (i.e. Android 8/Oreo lets you run in the background, but that lets you schedule an exact time of the day, on a daily basis?

Bourne
  • 2,518
  • 1
  • 20
  • 27
  • does this help? https://stackoverflow.com/questions/46304839/android-8-0-oreo-alarmmanager-with-broadcast-receiver-and-implicit-broadcast-ban – 10101010 Oct 25 '17 at 03:08
  • not sure but I think I read that Handler could be used for scheduling on a thread https://developer.android.com/reference/android/os/Handler.html – 10101010 Oct 25 '17 at 03:11

2 Answers2

0

Alarm Managers no longer work in the background in Android 8 (Oreo)

I am not aware of anything regarding AlarmManager that changed in Android 8.0. Feel free to point to documentation or an issue tracker entry to validate your claim. Or, file your own issue with a reproducible test case.

But in Android Oreo / 8.0, this isn't allowed anymore.

Sure it is, at least as well as it worked in Android 6.0 through 7.1. Doze mode and app standby have screwed with AlarmManager, but that's not new to Android 8.0.

Most background services, receivers, etc. are fairly limited.

They can still raise a Notification, which is what your question indicates that you want to do.

Does anyone know of a way to do this in Android Oreo in a way that it works even when the app is in the background?

Use AlarmManager. Since you are writing what amounts to an alarm clock app, use setAlarmClock().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Yes, thats an important clarification. Its not actually the alarm manager that is the problem, it is the limitations on what it can launch while the app is in the background. But ultimately, you can't use an alarm manager anymore for this type of functionality, i.e. setting a notification to go off at a specific time of day (every day). – Bourne Oct 30 '17 at 21:29
-1

one solution i can suggest may be solved your problem. you should start job schedule 15 minute repeater mode and call every minute one broadcast where you can check this current time is your specific time of day or not. if yes then send notification.

Mayur Dabhi
  • 3,607
  • 2
  • 14
  • 25