检查对Android设备的NFC功能 [英] Checking NFC feature on Android Device
问题描述
This is in response to question
Step #1: Put this in your manifest:
<uses-feature android:name="android.hardware.nfc" android:required="false" />
Step #2: Call hasSystemFeature(PackageManager.FEATURE_NFC) on PackageManager to see if NFC is available on the current device
我的API级别设置为8,第1步是确定的,但是当我写 hasSystemFeature(PackageManager.FEATURE_NFC)
它说 Feature_NFC
多年平均值解析为一个字段, Feature_WIFI FEATURE_BLUETOOTH FEATURE_CAMERA
在那里的选项。
我曾参观过 Android开发者网站,但他们没' ŧ提API级别。
另一个问题是,我可以在AVD测试NFC的应用程序?
人谁可以帮我这个
谢谢
i set the API level to 8,Step 1 is ok, but when I write hasSystemFeature(PackageManager.FEATURE_NFC)
it says Feature_NFC
doesnot resolve to a field,Feature_WIFI FEATURE_BLUETOOTH FEATURE_CAMERA
are the options there.
I have visited Android developer Site,but they didn't mention the API level.
Another question is Can I test NFC application on AVD?
Anyone who can help me this
Thanks
推荐答案
请确保您的项目构建目标设定为至少API 9级。
Make sure you are setting project build target to at least api level 9.
在包含的manifest.xml folliwng
Include folliwng in manifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" /> //If you have icecream sandwich installed.
这将确保您的应用程序将可运行在8 SDK还
It will ensure that your application will be runnable on sdk 8 also
另外,还要确保每当您呼叫的姜饼特定功能然后将它们包装成if条件
如下:
Also make sure whenever you are calling Gingerbread specific features then wrap them into if condition as follows.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
} else {
if (getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_NFC)) {
//do processing
}
}
测试你可以给一个尝试打开NFC Android模拟器
这篇关于检查对Android设备的NFC功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!