简体   繁体   中英

Android NFC: Reading tag does not work

I want to create an application that can read a tag. I copied the NFCDemo code, but that did not work. I also added

<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED" />
  <data android:mimeType="mime/type" />
</intent-filter>
<intent-filter>
  <action android:name="android.nfc.action.TECH_DISCOVERED" />
  <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
    android:resource="@xml/nfc_tech_filter" />
</intent-filter>
<intent-filter>
  <action android:name="android.nfc.action.TAG_DISCOVERED" />
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

to my manifest file.

But the application is never called / opened when I hold the tag at my Nexus S.

Thanks for any help!!

To make it easy at the beginning, remove all the intent filters but the TAG_DISCOVERED one. This is the most basic one. Once the NFC chip will discover a NFC tag, it will send out and event with TAG_DISCOVERED. If you have registered teh intent filter to an activity you should then see the intent chooser with your app in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM