Android NFC启动服务
我很好奇 Android NFC 服务
是否允许开发者在 NFC
时启动 Service
(或 IntentService
)代码>标签被扫描?
来自 Android 开发者:
当设备扫描带有
NDEF
数据的标签,但无法扫描时 映射到MIME
或URI
,标签调度系统尝试启动一个 具有ACTION_TECH_DISCOVERED
意图的活动。
看来只能启动新的 Activity,而不能启动 Service,尽管它可以接收相同的 Intent 过滤器。
I'm curious if Android NFC service
allows the developer to start a Service
(or IntentService
for that matter) when NFC
tag is scanned?
From Android Developers:
When a device scans a tag that has
NDEF
data on it, but could not be
mapped to aMIME
orURI
, the tag dispatch system tries to start an
activity with theACTION_TECH_DISCOVERED
intent.
It appears that only a new Activity can be launched, not Service, although it could receive the same Intent filter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然不是直接方法,但您可以有一个准系统的 Activity,它会立即启动服务,然后退出:
Although not the direct method, you could have a barebones
Activity
that will immediately start a service, then quit: