setExact()并
setAlarmClock()都作出非常类似的电话
setImpl()。如果
RTC_WAKEUP用于
setExact()呼叫,则唯一的区别是type的最终arg
AlarmClockInfo。
在服务端,该调用在set()中接收。在该方法的最后,我们可以看到额外参数带来的不同:
@Overridepublic void set(int type, long triggerAtTime, long windowLength, long interval, int flags, PendingIntent operation, WorkSource workSource, AlarmManager.AlarmClockInfo alarmClock) { final int callingUid = Binder.getCallingUid(); if (workSource != null) { getContext().enforcePermission( android.Manifest.permission.UPDATe_DEVICE_STATS, Binder.getCallingPid(), callingUid, "AlarmManager.set"); } // No incoming callers can request either WAKE_FROM_IDLE or // ALLOW_WHILE_IDLE_UNRESTRICTED -- we will apply those later as appropriate. flags &= ~(AlarmManager.FLAG_WAKE_FROM_IDLE | AlarmManager.FLAG_ALLOW_WHILE_IDLE_UNRESTRICTED); // only the system can use FLAG_IDLE_UNTIL -- this is used to tell the alarm // manager when to come out of idle mode, which is only for DeviceIdleController. if (callingUid != Process.SYSTEM_UID) { flags &= ~AlarmManager.FLAG_IDLE_UNTIL; } // If the caller is a core system component, and not calling to do work on behalf // of someone else, then always set ALLOW_WHILE_IDLE_UNRESTRICTED. This means we // will allow these alarms to go off as normal even while idle, with no timing // restrictions. if (callingUid < Process.FIRST_APPLICATION_UID && workSource == null) { flags |= AlarmManager.FLAG_ALLOW_WHILE_IDLE_UNRESTRICTED; } // If this is an exact time alarm, then it can't be batched with other alarms. if (windowLength == AlarmManager.WINDOW_EXACT) { flags |= AlarmManager.FLAG_STANDALONE; } // If this alarm is for an alarm clock, then it must be standalone and we will // use it to wake early from idle if needed. if (alarmClock != null) { flags |= AlarmManager.FLAG_WAKE_FROM_IDLE | AlarmManager.FLAG_STANDALONE; } setImpl(type, triggerAtTime, windowLength, interval, operation, flags, workSource, alarmClock, callingUid);}如果存在非null
alarmClock参数,则请求会
FLAG_WAKE_FROM_IDLE在的顶部获得标志,
FLAG_STANDALONE在两种情况下都会获得该标志。的评论为
FLAG_WAKE_FROM_IDLE:
警报标记:即使设备处于空闲状态,此警报也要唤醒设备。例如,这是用于闹钟的警报。
如果需要,您可以深入了解-
的用法
FLAG_WAKE_FROM_IDLE,据我所知,就是这样。您的“正常”确切警报不会将设备从空闲状态唤醒,但是使用setAlarmClock()设置的警报会唤醒。



