IntentService和AlarmManager通信

编程入门 行业动态 更新时间:2024-10-26 16:24:52
本文介绍了IntentService和AlarmManager通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

应该报警管理器发送的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通信

本文发布于:2023-11-27 06:27:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636966.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通信   IntentService   AlarmManager

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!