janot
janot

Reputation: 14592

How to set android permissions in Phonegap

I've tried to add following lines in the end of "project_root"/www/config.xml (got it from plugin.xml of one of previously installed plugins):

<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest">
        <uses-permission android:name="android.permission.INTERNET"/>
    </config-file>
</platform>

But as expected this doesn't work. I need it for InAppBrowser plugin to load online pages (I don't want to edit it's plugin.xml, because plugin can be updated or reinstalled -> changes will be wiped).

Upvotes: 3

Views: 6245

Answers (2)

JCK&#246;del
JCK&#246;del

Reputation: 780

1) Add the android namespace to the <widget>: xmlns:android="http://schemas.android.com/apk/res/android"

2) Add this to your platform@name=android:

<platform name="android">
    <config-file parent="/*" target="AndroidManifest.xml">
        <uses-permission android:name="android.permission.RECEIVE_SMS" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    </config-file>
</platform>

3) Done (of couse, apply the desired permissions)

Your AndroidManifest.xml file will have the desired permissions (even if you delete the platforms folder):

    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
</manifest>

Upvotes: 1

pg316
pg316

Reputation: 1398

I think the problem may be that you are editing the wrong file. When you create a new cordova project using the CLI it places a config file for you here "project_root/config.xml". Check to see if you have a config file in that location. If so then make your changes in that file and it should work.

Upvotes: 0

Related Questions