从服务中捕获NFC NDEF_DISCOVERED意图 [英] Catch NFC NDEF_DISCOVERED intent from a service

查看:362
本文介绍了从服务中捕获NFC NDEF_DISCOVERED意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个始终在后台运行的服务,有没有办法可以在我的服务中捕获NDEF_DISCOVERED意向过滤器?这样,当我的两个设备准备就绪时,就可以在服务中捕获该代码并根据需要进行操作吗?

I have a service which is always running in the background, is there a way that I can catch an NDEF_DISCOVERED intent filter in my service? So that once my two devices are ready to beam I can catch that code in a service and manipulate it as I need too?

推荐答案

NFC意图,即

  • android.nfc.action.NDEF_DISCOVERED,
  • android.nfc.action.TECH_DISCOVERED和
  • android.nfc.action.TAG_DISCOVERED,

仅发送给活动.因此,您不能直接从服务中捕获它们.但是,您可以让该意图启动一个活动,然后该活动将调用该服务.

are only sent to activities. Thus, you cannot catch them from a service directly. However, you could let the intent launch an activity, which then invokes the service.

这篇关于从服务中捕获NFC NDEF_DISCOVERED意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆