Android AlarmManager stops when activity die

前端 未结 9 2118
鱼传尺愫
鱼传尺愫 2020-12-29 07:00

I start AlarmManager with PendingIntent and on few phones Alarm is not responding. On some devices is working ok on others it fails. I have made a few tests on different pho

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 07:17

    This is only a guess but I think the issue has to do with the API. Starting with KitKat, the system messes up the AlarmManager. Perhaps consider trying using something else for systems at abd above kitkat.

    "Note: Beginning with API 19 (KITKAT) alarm delivery is inexact: the OS will shift alarms in order to minimize wakeups and battery use. There are new APIs to support applications which need strict delivery guarantees; see setWindow(int, long, long, PendingIntent) and setExact(int, long, PendingIntent). Applications whose targetSdkVersion is earlier than API 19 will continue to see the previous behavior in which all alarms are delivered exactly when requested. "

    Taken from http://developer.android.com/reference/android/app/AlarmManager.html

提交回复
热议问题