【发布时间】:2013-02-12 13:22:22
【问题描述】:
我对 IntentService 的使用有点困惑。
- 文档说 IntentService 将发送给它的所有意图排队并一次处理一个。
- 我查看了code of IntentService,发现 onStartCommand() 接收到意图,调用 onStart() 将其作为消息发送给意图排队
我很确定我在文档中读到过 onStartCommand() 只被系统调用一次,如果你发出两次 startService(),第二次调用不会导致 onStartCommand() 被调用。
我在这里可能错了,因为我一直在寻找这篇文档,但似乎找不到。
这与之前的概念相矛盾,即您可以通过 onStartCommand() 在 IntentService 中排队许多意图。
所以我需要帮助,如何在 IntentService 上排队多个意图?
我只看到两个选项:
只需每次调用 startService() 以不同的意图
直接调用onStart()或onStartCommand()(绕过startService())
【问题讨论】:
标签: android service intentservice