Android permissions in Cordova 4.0 config.xml

与世无争的帅哥 提交于 2020-01-15 20:08:47

问题


I used Cordova 4.0 to create a phonegap app (that has worked fine via cli on iOS), but I also want to use build.phonegap.com particularly for Android.

The main issue is that upon installing the APK on Android, the security warning lists all features, when I do not actually need any.

I have read that you can remove all permissions with <preference name="permissions" value="none" />and then selectively add back the ones you want.

However, this is not working; I still get all the permissions requested upon install. I must be missing something, or something has changed. (Did I make a mistake using Cordova instead of Phonegap? That's reasonably easy to correct..)

My config.xml is below:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test" version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:gap="phonegap.com/ns/1.0"
xmlns:android = "http://schemas.android.com/apk/res/android">
    <name>Test</name>
    <description>
        Test.
    </description>
    <author email="test@test.com" href="http://test.com">
        Test
    </author>
    <content src="index.html" />
    <access origin="*" />

    <gap:plugin name="org.apache.cordova.statusbar" />
    <preference name="StatusBarOverlaysWebView" value="false" /> 
    <preference name="StatusBarBackgroundColor" value="#ffffff" />
    <preference name="StatusBarStyle" value="default" />
    <preference name="DisallowOverscroll" value="true" />

    <preference name="permissions" value="none" />

</widget>

Edit: To remove ambiguity, I want to remove the Android security warnings saying this app needs full access to contacts, camera, internet access, etc. I do not need any of these.


回答1:


config.xml , is just a bunch of information. It is not executed sequentially. so if you mention you require DisallowOverscroll permission and then mention you dont require any permission, it means ,

<preference name="permissions" value="none" /> 

will not overWrite

<preference name="DisallowOverscroll" value="true" />

for example:

 <preference name="DisallowOverscroll" value="true" />

    <preference name="permissions" value="none" />

and

<preference name="DisallowOverscroll" value="true" />

<preference name="permissions" value="none" />

both are same.



来源:https://stackoverflow.com/questions/27126194/android-permissions-in-cordova-4-0-config-xml

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