问题
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