应该报警管理器发送的PendingIntent到IntentService还是更将其发送到广播接收器,然后发出startService()针对未决的意图是什么?
Should alarm manager send PendingIntent to IntentService or is it better to send it to a broadcast receiver which then issues startService() targeting the pending intent?
推荐答案这取决于这是否是一个 _WAKEUP 报警或不是有点。
That depends a bit on whether this is a _WAKEUP alarm or not.
如果没有,随意使用的getService() 的PendingIntent 。
If not, feel free to use a getService() PendingIntent.
如果,但是,它是一个 _WAKEUP 报警,你不仅需要使用广播接收器中介,但广播接收器还必须获取激活锁定其中 IntentService 更高版本。在广播接收器要求是由于方式 AlarmManager 处理自己的激活锁定。我已经包裹所有这一切都成一个 WakefulIntentService 简化实施
If, however, it is a _WAKEUP alarm, not only do you need to use a BroadcastReceiver intermediary, but that BroadcastReceiver must also acquire a WakeLock which the IntentService later releases. The BroadcastReceiver requirement is due to the way AlarmManager handles its own WakeLock. I have wrapped all of this up as a WakefulIntentService to simplify the implementation.
更多推荐
IntentService和AlarmManager通信
发布评论