android - 仅向一项服务发送 Intent

标签 android service android-intent intentfilter

当一项服务正在运行时,是否可以仅向该服务发送 Intent ? 我知道函数 startService()onStartCommand() 但我不想“启动”服务,在我的情况下它已经启动了。 p>

所以我想知道是否可以仅针对一个广播接收器,或者它是否退出其他内容以仅发送到一个服务/Activity ?

sendBroadcast(intent) 之前我对 intent.setClass() 的尝试没有得出结果。

最佳答案

I'm aware of the functions startService() and onStartCommand() but I don't want "start" the service, in my case it was already started.

startService() 仅通过 onStartCommand() 将消息传递给现有正在运行的服务副本(如果存在这样的副本)。如果没有正在运行的服务副本,它将创建这样的副本(从而触发对 onCreate() 的调用)。

So I would like to know if it is possible to target only one brodcast receiver or if it exits something else to send only to one service/activity?

请使用startService()

关于android - 仅向一项服务发送 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11136922/

相关文章:

android - android中的TabGroup Activity问题

android - 记录广播 Intent 并手动触发它们(Android)

java - 如何发送带有打开 Android 应用程序链接的电子邮件

android - Eclipse + Android SDK,不会获取、更新、连接或做任何有用的事情

android - 如何在sqlite(android)中创建一个sql View (CREATE VIEW)并查询?

c# - 如何使用 Visual Studio 2010 将 Windows 控制台应用程序 C# 项目更改为 Windows 服务?

java - 服务以错误的时间间隔执行短信

java - 微服务架构 DVD 租赁应用

android - 如何过滤android文件选择器应用程序

android - NestedScrollView 剪切/覆盖嵌套 fragment 的底部