Substitute for Alarm Manager - Android

a 夏天 提交于 2021-01-27 14:12:04

问题


Seriously, What is the solution to do a simple task like sending notifications when app is not running? (Using devices with custom OS like Xiaomi)

When alarm is set, it works for short period of times like a few minutes, but not for long periods of time like hours. (although it works perfectly fine on some devices and also when the app is running)

I have read hundreds of threads and no one has a concrete solution for this. None of the recommended methods work, I tried the following:

  1. Alarm manager + Broadcast Receiver + BackgroundService (Works on some devices, not all)
  2. Alarm manager + Broadcast Recevier + foregroundService (worked a few time but then just stopped working!) I tried intentservice, jobintent service and none worked.
  3. WorkManager (the work is delayed indefinitely, some times 15 minutes some times an hour, some times 10 hours)
  4. Added Wakelock (didin't change anything)
  5. Alarm manager + IntentService (doesn't work)
  6. Setting a process name to the service(doesn't change anything)
  7. Some thread and also Google guys say that there is no solution at the moment. However I have seen apps that managed to make it work!

I read about dontkillmyapp and I am aware of the issue. But I have one app that somehow managed to send notifications at very exact times. It is not a famous app like Whatsapp. There must be a solution.

来源:https://stackoverflow.com/questions/63501496/substitute-for-alarm-manager-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!