1
votes

Is there any way I can check whether the device can read and write Mifare classic NFC tags? I am writing an app which main use case is to read and write Mifare classic tags, so if it can not, the app should show a message and close.

2

2 Answers

1
votes

Using the classes in android.nfc.tech you can enumerate a list of TagTechnologies from a scanned tag.

From the documentation at https://developer.android.com/reference/android/nfc/tech/TagTechnology.html:

It is mandatory for all Android NFC devices to provide the following TagTechnology implementations.

  • NfcA (also known as ISO 14443-3A) NfcB (also known as ISO 14443-3B)
  • NfcF (also known as JIS 6319-4) NfcV (also known as ISO 15693) IsoDep
  • Ndef on NFC Forum Type 1, Type 2, Type 3 or Type 4 compliant tags

It is optional for Android NFC devices to provide the following TagTechnology implementations. If it is not provided, the Android device will never enumerate that class via getTechList().

  • MifareClassic
  • ...

(emphasis mine)

I am not sure if this is enough for you or if you need to distinguish between a tag simply not offering Mifare Classic and the device not implementing support for it? Or even, if you need to determine device support before even scanning a tag?

0
votes
 public boolean deviceSupportsMifareClassic() {
    FeatureInfo[] info = mContext. getPackageManager().getSystemAvailableFeatures();
    for (FeatureInfo i : info) {
        String name = i.name;
        if (name != null && name.equals("com.nxp.mifare")) {
            return true;
        }
    }
    return false;
 }