am.setExact(AlarmManager.RTC_WAKEUP, atTimeInMillis, sender);
系统版本是5.1.1 也使用的电源锁 按下电源键黑屏后就会出现闹钟时间不准,或者按亮屏幕后就立马响了
if (sCpuWakeLock != null) {
return;
}
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
sCpuWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "AlarmClock");
sCpuWakeLock.acquire();
参考: