Avoid Android Market filtering on optional use of

2019-02-22 04:38发布

问题:

In my app I try and use location information if it is available. Hence I have those permissions in my manifest:

e.g.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

NOTE: I DO NOT have a for location, which is the tag I understood was used for filtering in Android Market.

When I upload to Android market I get this reported:

This apk requests 4 features that will be used for Android Market filtering android.hardware.location.network android.hardware.location android.hardware.location.gps android.hardware.touchscreen

which to me suggests that it will only show up for devices that have location and location.network and gps hardware.

But my use of location is optional and the app will work if it is not avaialble.

Should I remove those permissions from my manifest (will I get exceptions when I try to use it?)?

Is there a way to leave the permissions and avoidAndroid Market filtering based on them?

回答1:

My application has the same problem. I guess this is because the minSdkVersion is 4, i.e. Android 1.6. From the <uses-feature> documentation:

In general, if your application is designed to run on Android 1.6 and earlier versions, the android:required attribute is not available in the API and Android Market assumes that any and all declarations are required.

This makes sense because when you declare a feature as optional, you are supposed to use the hasSystemFeature() method from the PackageManager to check whether the current device has that particular feature. However, this method itself is available only from API Level 5!