我的要求很简单。
我有一个简单的应用程序。 2 个按钮。和 1 项服务。 条件: Button1 单击,-> 启动 IntentService。Button2 单击 -> 停止 IntentService。
第一部分工作正常。我可以使用 startService(intent) 命令启动 IntentService。 但是,我无法停止 IntentService。即,stopService(intent) 命令不起作用。 它既不抛出错误也不做任何事情。
谁能解释一下这个??
我搜索并找到了这个问题 How to stop an IntentService? 但它不能满足我的需求。
最佳答案
您不能手动停止 IntentService
。 IntentService
将在该服务不再有要处理的 Intent 时自动停止。
如果您想通过单击按钮来停止服务,请使用普通的服务
。
关于android - 如何停止 android Background IntentService?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28010257/