Android Permission, required=“false”, fail

2019-06-16 03:49发布

My application provides the user with optional access to SMS and Phone calls. I have used:

 <uses-permission android:name="android.permission.READ_PHONE_STATE" android:required="false"></uses-permission>
 <uses-permission android:name="android.permission.SEND_SMS" android:required="false"></uses-permission>
 <uses-permission android:name="android.permission.CALL_PHONE" android:required="false"></uses-permission>

Google Play does not expose this application to devices that do not have cellular network access. It seems like the required = false parameter is failing to do its job.

Is this a bug? Is there something else that I can do?

3条回答
Fickle 薄情
2楼-- · 2019-06-16 04:19

Why are you putting the required parameter inside a permission? The android:required param is used when you declare a feature, afaik... For example:

<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />

I think what you wanted to do is add uses-feature declarations with android:required="false".

Use this table to update your manifest: http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features

<uses-feature android:name="android.hardware.telephony" android:required="false" />
查看更多
叛逆
3楼-- · 2019-06-16 04:29

You don´t need to use the property android:required in <uses-permission it only works for <uses-feature, see the definition of

uses-feature : To control filtering, always explicitly declare hardware features in elements, rather than relying on Google Play to "discover" the requirements in <uses-permission> elements. Then, if you want to disable filtering for a particular feature, you can add a android:required="false" attribute to the declaration.

this is the list of permissions that imply hardware features:

https://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features

Based on your elements:

you probably need to add only :

<uses-feature android:name="android.hardware.telephony" android:required="false" />
查看更多
在下西门庆
4楼-- · 2019-06-16 04:34

You can see all the permissions in the permissions tab in the AndroidManifest.xml file.

查看更多
登录 后发表回答