1

I write the NFC related declaration in the AndroidManifest like below:

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

I hope in this way, google play will not filter my app in the phone without NFC function. But unfortunately, I checked the installed app, found the NFC is still required....just don't know why

PackageManager pm = getPackageManager();
try {
    PackageInfo packageInfo1 = pm.getPackageInfo("My pakcage name", PackageManager.GET_CONFIGURATIONS);
    if(packageInfo1 != null && packageInfo1.reqFeatures != null) {
        for(FeatureInfo featureInfo : packageInfo1.reqFeatures) {
            Log.d("TAG", "name:"+featureInfo.name + ", flag:" + featureInfo.flags+",version:"+featureInfo.version);
        }
    }
} catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
}

The output:

03-15 12:21:56.673 17052-17052/mapbox1.myapplication D/TAG: name:android.hardware.nfc.hce, flag:1,version:0

The flag in the FeatureInfo is 1, which means required....

I paste my Manifest below, removing activities and services, etc: enter image description here

And the full output:

03-15 12:41:02.982 17052-17052/mapbox1.myapplication D/TAG: name:android.hardware.bluetooth_le, flag:1,version:0

03-15 12:41:02.982 17052-17052/mapbox1.myapplication D/TAG: name:android.hardware.nfc.hce, flag:1,version:0

03-15 12:41:02.982 17052-17052/mapbox1.myapplication D/TAG: name:android.hardware.camera, flag:1,version:0

03-15 12:41:02.982 17052-17052/mapbox1.myapplication D/TAG: name:android.hardware.camera.autofocus, flag:0,version:0

The required=false in autofocus worked as desired, but NFC's required attribute not working. (android.hardware.camera's required not working, probably because of the android.permission.CAMERA)

Community
  • 1
  • 1
mianlaoshu
  • 2,342
  • 3
  • 27
  • 48
  • From: https://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions It looks like feature `android.hardware.nfc.hce` is deprecated. Just try with `android.hardware.nfc` – Morrison Chang Mar 15 '18 at 04:54

1 Answers1

1

I suspect there are the 3rd libraries overriding this, so I just add the tools:replace="android:required" to use the App's android:required="false". This solves my problem

mianlaoshu
  • 2,342
  • 3
  • 27
  • 48