0

Please help me out, a wakeful broadcast receiver is not called, I have set an Alarm with the help of Alarm Manager using setExactAndAllowIdle() with RTC_WAKEUP but still, my broadcast receiver not getting called when App is closed (means App is swiped from Recent Apps). I am working on android 8. Actually, I want to create an Alarm App that fires at the exact time which set, even if the App is closed or the device is locked.

2 Answers2

0

Here is what you need to check out:

Alarm manager is not working with long term tasks

How to use Android AlarmManager in Fragment in Kotlin?

All the information you need can be found in those topics.

Vitaliy-T
  • 733
  • 6
  • 23
0

It may be because the WakefulBroadcastReceiver has been deprecated as of Android O and should generally not be used anymore. From the documentation:

Deprecated: As of Android O, background check restrictions make this class no longer generally useful. (It is generally not safe to start a service from the receipt of a broadcast, because you don't have any guarantees that your app is in the foreground at this point and thus allowed to do so.) Instead, developers should use android.app.job.JobScheduler to schedule a job, and this does not require that the app hold a wake lock while doing so (the system will take care of holding a wake lock for the job).

https://developer.android.com/reference/kotlin/androidx/legacy/content/WakefulBroadcastReceiver

patrick.elmquist
  • 2,113
  • 2
  • 21
  • 35