如何检测设备是否可以读写 Mifare 经典 NFC​​ 标签?

How to detect if device can read and write Mifare classic NFC tag?

有什么方法可以检查设备是否可以读写Mifare classic NFC标签?我正在编写一个主要用例是读写 Mifare 经典标签的应用程序,因此如果不能,该应用程序应显示一条消息并关闭。

使用 android.nfc.tech 中的 类 您可以从扫描的标签中枚举 TagTechnologies 列表。

来自 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
  • ...

(强调我的)

我不确定这对您来说是否足够,或者您是否需要区分不提供 Mifare Classic 的标签和 设备 不支持它?或者甚至,如果您需要在扫描标签之前确定设备支持?

 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;
 }