Android 中具有优先级队列的服务
我想实现一个 IntentService (源代码) 基于简单的数字优先级处理意图。服务应首先处理优先级较高的意图,而不是优先级较低的意图。
Android 上有什么东西可以做到这一点吗?如果没有,有关于如何实施的指导吗?
I'd like to implement an IntentService (source code) that handles intents based on a simple numeric priority. Intents with higher priority should be processed first by the service than intents with lower priority.
Is there anything on Android that does this already? If not, any pointers on how to implement it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首次尝试基于 CommonsWare 的回答和 Android 的
IntentService
源代码。将进行广泛测试并进行相应编辑。A first attempt at an implementation of a intent service with priorities, based on CommonsWare's answer and Android's
IntentService
source code. Will test extensively and edit accordingly.并不真地。不过,
IntentService
并没有太多内容。烹制一个由PriorityBlockingQueue
支持的PriorityIntentService
,而不是Handler
+Looper
,应该不会太长。Not really. There isn't much to
IntentService
, though. Cooking up aPriorityIntentService
backed by aPriorityBlockingQueue
, rather than aHandler
+Looper
, shouldn't be much longer.