How would you open your application directly using an intent filter when using the NFC service with a Mifare card? I know that you can use an intent filter using a specific mimeType directly for a P2P Connection like
<data android:mimeType="application/com.sticknotes.android"/>
I’m just not sure how I’d set up the sectors of a Mifare1K to do the same thing. Anybody have any ideas on how to do this? Or am I just limited to having the application chooser pop-up?
I suppose I could create a completely separate activity to handle passive tags versus active devices but is there any way to handle this all in one activity??
If your app already has an intent filter for the MIME type “application/com.sticknotes.android” that works with Android Beam (P2P connection), then it will also work with tags that contain and NDEF message with the same MIME type. Android Beam and tag discovery both generate an
ACTION_NDEF_DISCOVEREDintent in the receiving/reading device.To write such an NDEF message to a MIFARE Classic 1K tag, you can create a simple app that does that for you. In this app’s manifest file put:
And in project’s
res/xmlfolder put a filenfc_tech_filter.xmlwith the following contents:In the app’s
Activityput:This formats and writes an NDEF message to unformatted (blank) MIFARE Classic tags or overwrites tags that are already formatted with NDEF. If you want to write other tag types besides MIFARE Classic ones, adjust
nfc_tech_filter.xmlaccordingly.