req*_*nce 2 android nfc android-virtual-device android-emulator
这是对问题的回应
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
Run Code Online (Sandbox Code Playgroud)
我将API级别设置为8,步骤1没问题,但是当我写hasSystemFeature(PackageManager.FEATURE_NFC)它时说不Feature_NFC解析为字段,Feature_WIFI FEATURE_BLUETOOTH FEATURE_CAMERA那里是选项.我访问了Android开发者网站,但他们没有提到API级别.另一个问题是我可以在AVD上测试NFC应用吗?有人可以帮我这个谢谢
确保将项目构建目标设置为至少api级别9.
在manifest.xml中包含folliwng
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" /> //If you have icecream sandwich installed.
Run Code Online (Sandbox Code Playgroud)
它将确保您的应用程序也可以在sdk 8上运行
还要确保无论何时调用Gingerbread特定功能,然后将其包装到if条件中,如下所示.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
} else {
if (getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_NFC)) {
//do processing
}
}
Run Code Online (Sandbox Code Playgroud)
测试您可以尝试打开NFC Android模拟器
| 归档时间: |
|
| 查看次数: |
3742 次 |
| 最近记录: |