1

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.

Mark Buikema
  • 2,483
  • 30
  • 53
  • http://stackoverflow.com/questions/15775832/exclude-non-nxp-android-phones-with-nfc-like-the-nexus-4-10 – ThomasRS Sep 12 '16 at 13:37

2 Answers2

1

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?

JHH
  • 8,567
  • 8
  • 47
  • 91
  • I want to determine the device support when opening the app, without having to scan a tag. – Mark Buikema Sep 09 '16 at 08:28
  • There doesn't seem to be any published API for that I'm afraid. I couldn't find any obvious hidden API's either, if that would have helped you. This is likely up to the specific NFC implementation of the device. – JHH Sep 09 '16 at 08:41
  • You can detect whether NXP chip is available on the device, however this is not rock solid. – ThomasRS Sep 12 '16 at 13:38
  • Yes but would this give a conclusive answer to the OPs question? Nxp likely would support classic, but what's to say others won't too? – JHH Sep 12 '16 at 13:40
0
 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;
 }
Mark Buikema
  • 2,483
  • 30
  • 53