Catch NFC NDEF_DISCOVERED intent from a service

柔情痞子 提交于 2019-12-11 02:52:23

问题


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?


回答1:


The NFC intents, that is

  • android.nfc.action.NDEF_DISCOVERED,
  • android.nfc.action.TECH_DISCOVERED, and
  • 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.



来源:https://stackoverflow.com/questions/19452368/catch-nfc-ndef-discovered-intent-from-a-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!