Tino A.
Tino A.

Reputation: 232

Ionic App on Android Marshmallow repeatedly asking for permission, even after granting it

Whenever I try to select an image from my gallery the permission window pops up, asking if the app should be allowed to access my media storage. After allowing it everything works fine. The next time I want to select an image from my gallery however, the app asks for the same permission again.

Here are the options for my cordova camera plugin:

image_options = {
    destinationType: Camera.DestinationType.DATA_URL,
    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
    correctOrientation: true,
    cameraDirection: 0,
    allowEdit: true,
    encodingType: Camera.EncodingType.JPEG
  };

Here is the (generated) AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.mycompany.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
    <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
        <intent-filter android:label="@string/launcher_name">
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>

I have ensured that in the settings the app also is allowed to access "Storage".

Is there anything obvious I might be doing wrong?

Upvotes: 1

Views: 440

Answers (1)

Tino A.
Tino A.

Reputation: 232

After days of googling and trying stuff I finally solved the problem by manually adding the CAMERA permission to the android manifest. First of all I was under the impression that the complete manifest is created on the ionic build/run. Secondly its a bit strange I had to add the camera permission to get the storage permission to work, especially since taking photos was no problem.

Upvotes: 1

Related Questions