Android AlarmManager stops when activity die

前端 未结 9 2126
鱼传尺愫
鱼传尺愫 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条回答
  •  梦毁少年i
    2020-12-29 07:14

    Try the following:

    1) Add teh Wake_lock permission to your manifest.

    
    

    2) Change

    alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 1000, 5000, pendingIntent);
    

    with

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000, 5000, pendingIntent);
    

提交回复
热议问题