获取 Intent 传递给 Service 中的 stopService(intent)

Get Intent passed to stopService(intent) in Service

我需要检测破坏服务的来源。 我在调用

时使用了 intent 和 extra

停止服务(意图)。

但是在服务 class 中捕获此意图以采取行动的位置。 已经浏览了 android 个文档,但没有找到任何有用的信息。 非常感谢任何帮助。

现在,我相信马克墨菲所说的不可能。作为替代方案,您可以在 Service 中注册一个 BroadcastReceiver 以停止服务,然后从您的整个应用程序向此 receiver 发送广播。在这里,您可以获得从 intent 发送到 receiver 的所有信息。在 receiver 中,只需调用 stopSelf().