如何给条件,Android应用程序只在支持NFC的设备上运行?
问题描述:
我开发一种阅读NFC标签细节的应用程序。在该应用程序我想给只有在NFC可用设备运行状态。
I developing a application which read the NFC Tag details.. In that application i want to give the condition to run only in NFC available devices..
先谢谢了...
答
如果您包括这在你的清单您的应用程序只能在有NFC设备上运行:
If you include this in your manifest your app will only be able to run on devices that have NFC:
<uses-feature android:name="android.hardware.nfc" android:required="true" />
NfcAdapter.getDefaultAdapter(本)
也可以返回空
具有NFC设备,但NFC功能上是由于某些原因在这种情况下,无法使用。
NfcAdapter.getDefaultAdapter(this)
can also return null
on a device which has NFC, but the NFC functionality is unavailable for some reason in that case.