AlarmManager not fires on time in Android Lollipop

落爺英雄遲暮 提交于 2019-12-10 14:25:26

问题


i'm using this code to set Alarm in Android KitKat and lollipop:

    AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
    Intent i = new Intent(AlarmService.this, Reciver.class);
    PendingIntent pi = PendingIntent.getBroadcast(AlarmService.this, 1201, i, PendingIntent.FLAG_UPDATE_CURRENT);
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, 9);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    am.setExact(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pi);

this code is works good on Android KitKat but on Android Lollipop its fires With 10 or 5 minutes delayed.


回答1:


This is a known bug in Android Lollipop and has been reported by several other users on Android's official bug tracker. There's no immediate solution to this problem, but you can get updates regarding this issue here: https://code.google.com/p/android/issues/detail?id=82001



来源:https://stackoverflow.com/questions/27668444/alarmmanager-not-fires-on-time-in-android-lollipop

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