AlarmManager not working properly

后端 未结 2 1295
傲寒
傲寒 2021-01-05 01:48

I\'m trying to create an alarm based application. I\'m using AlarmManager. The thing is that it\'s not reliable at all. In some devices it works.. in other devi

2条回答
  •  执笔经年
    2021-01-05 02:27

    In addition to marcin´s answer, another reason could be a build in task-manager/energy-manager. If you write, your alarm works fine on some devices and in some not, it could be because of lower/higher APIs like Marcin suggested. But there is another thing that I have explored on my Huawei Ascend Mate 7: Some devices have an energy control system inside that directly closes the application completely after screen goes off. I had the same problem with one of my apps with an alarm manager and nothing helped, wether a usual service nor a foreground service nor any other programming solution. It was just simple: I had to go to settings-->energy saving mode-->protected apps. Here you have to enable the protection of your app.

    It may be that this is not the solution in Your case, but it is in much other devices and this explanation is too long for a comment, so I have to put it as answer.

提交回复
热议问题