Checking NFC feature on Android Device

隐身守侯 提交于 2019-12-06 09:55:18

Make sure you are setting project build target to at least api level 9.

Include folliwng in manifest.xml

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" /> //If you have icecream sandwich installed.

It will ensure that your application will be runnable on sdk 8 also

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

For testing You can give a try to Open NFC Android emulator

FEATURE_NFC is defined from API Level 9, but you can still use the constant value "android.hardware.nfc".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!