在Android设备上检测NFC设备、Android、NFC

2023-09-05 06:30:36 作者:小任性

嗯,我的目的是为了检测是否在Android设备支持NFC,如果没有,我会用一些其他的技术。我已经把我的最低API级别为8,因为我想我的应用程序的功能,即使在这些设备上没有NFC。

Well, my purpose is to detect if the Android device supports NFC and if not I will use some other technology. I have set my minimum API level to 8 as I want my app to function even on these devices without NFC.

有没有像isNFCSupported()的方法?任何想法?

Is there a method like isNFCSupported()? any ideas?

谢谢 yosoh。

推荐答案

第1步:将这个在你的清单:

Step #1: Put this in your manifest:

<uses-feature android:name="android.hardware.nfc" android:required="false" />

第二步:拨打hasSystemFeature(PackageManager.FEATURE_NFC)在 PackageManager 来看看NFC可在当前设备上

Step #2: Call hasSystemFeature(PackageManager.FEATURE_NFC) on PackageManager to see if NFC is available on the current device