Android Permission, required=“false”, fail

こ雲淡風輕ζ 提交于 2019-12-08 16:02:57

问题


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?


回答1:


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" />



回答2:


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




回答3:


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" />


来源:https://stackoverflow.com/questions/10707693/android-permission-required-false-fail

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