I want to register an application to be launched when an NFC tag is detected. From searching around I found that I need to use
[IntentFilter(new[] { NfcAdapter.ActionTechDiscovered })]
on the main activity. However, the app doesn't launch (nor am I prompted to choose an application). Instead, a generic tag reader opens up.
Where is the problem?
The ActionTechDiscovered intent filter requires a tech-list that specifies the tag technologies (or combinations of them) that your activity should be started for. You can specify the tech-list file using:
[IntentFilter (new[]{NfcAdapter.ActionTechDiscovered})]
[MetaData (NfcAdapter.ActionTechDiscovered, Resource="@xml/nfctech")]
You then need to place a file "nfctech.xml" into the folder "Resources/xml". Inside this file you can define all the tag technologies that you want to listen to. For instance, to listen for any tag technology, you would use:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.NfcA</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcB</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcF</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcV</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcBarcode</tech>
</tech-list>
</resources>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With