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.
-
check permission android.permission.WAKE_LOCK, also please provide source code – Style-7 Oct 23 '20 at 12:43
2 Answers
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.

- 733
- 6
- 23
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

- 2,113
- 2
- 21
- 35
-
Thanks for telling me about this, so please can you recommend any approach I should follow to create a Strict Time-Based Event?? – Abhishek Salecha Oct 23 '20 at 12:12