0

In my app I used Alarm manager for time scheduling. For that I used Alarm Manager API .

  • I am using setInExactRepeating() method for repeat my alarm but it's not triggering my alarm when my device is in idle condition. Also sometimes it delays to triggering alarm.
  • For my app its important to trigger the alarm at the exact time in repeating mode also in idle condition.

Please help how can i resolve this issue, I also learned about Job scheduler and Work manager but these have not a feature like alarm manager to set alarm at exact or repeat.

Thank You

Mohammad Khair
  • 436
  • 6
  • 15
Kaunain
  • 168
  • 3
  • 16
  • did you try this? https://stackoverflow.com/questions/48638494/android-alarmmanager-is-not-triggering-alarm-on-next-day-when-idle – Sahitya Pasnoor Dec 18 '20 at 08:01

1 Answers1

0

You probably can't do any with repeat because on higher android there is a limitation for repeating (i think 15m) for better performance and battery saving and Alarm manager on higher android isn't the best.

Even if you manage to do so and make your app it will probably be killed by performance controller applications or even android OS itself. and I don't suggest investing your time in it because of this.

There were few tricks to trick the android OS and get your app running but I think it will be really messy to code that. the best thing to work is the same WorkManager as you say

ErfanDP
  • 171
  • 5
  • But work manager has not a feature like a alarm manager how Can i replace . Have you any idea please suggest @ErfanDP – Kaunain Dec 18 '20 at 09:01
  • 1
    actually, the work Manager uses thing that the Alarm manager uses and it's kinda like wrapper class but there is some limitation that can not break witch feature of Alarm Manager you want to use? – ErfanDP Dec 18 '20 at 09:11
  • I want to use scheduling feature. Let me explain first, in my app there is a feature like time schedule , user can select a particular time and at that time the alarm should trigger with notification also it will be periodic and in alarm manager i am using broadcast receiver. so can you please suggest how can i do the same with work manager @ErfanDP – Kaunain Dec 18 '20 at 13:20
  • 1
    it's possible I think to get this done with the work manager https://medium.com/@pmaggi take a look at the work manager android doc first and get more familiar with the work manager then go to this link that I send he has 4 articles that I think will help you – ErfanDP Dec 20 '20 at 06:00
  • @ErfanDP But you cannot use `WorkManager` to (and I quote): "set alarm at exact or repeat". Work Manager scheduler will _decide_ if your job can run "when you said you wanted" or if other factors (battery/doze mode/etc.) should defer your work to a later time. Unless WM has changed in the last couple of years, this has always been like this. – Martin Marconcini Dec 21 '20 at 08:44