Problems with granting permissions

Hello guys,

How can I grant permission to write and read for an app using ARFoundation? When I add some functions that should grant a permission …

using UnityEngine.Android;
Permission.RequestUserPermission(Permission.ExternalStorageRead);

… it seems to get totally ommited and asks only for camera, which I believe is requested somewhere in ARCameraManager script. Is there special class / script for ARFoundation to use or introduce when I want to grant extra permissions? I am aware that, ARCore itself has something like GoogleARCore.AndroidPermissionsManager but it is not the case this time.

Hi,

I don’t think permission have anything to do with ARfoundation, the code you’ve been writtin is the Android permission API by Unity:

Make sure ExternalStorageRead is in your Android Manifest file.

Also if you already have permission for ExternalStorageRead, you won’t get a request for it.

I would also try with other permissions like the Permission.ExternalStorageWrite (I don’t use the Read, only the write since it does both )

Unity might already be requesting ExternalStorageRead by default (at install-time?)
Just a guess though. Trying some other permission-types might provide more details.

Thanks for the responses. I have added a line about write permissions using this code:

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player" xmlns:android="http://schemas.android.com/apk/res/android" tools:node="merge">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <application>
        <activity android:theme="@style/UnityThemeSelector" android:name="com.unity3d.player.UnityPlayerActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true"/>
        </activity>
    </application>
</manifest>

I have checked and manifest in apk got the line , nonetheless when app is running first time it asks only for camera permission.

I was looking for a solution to this problem because I am trying to control a GPIO microcontroller via usb through AR Foundation based app. I am getting an error: IOException: Permission denied so I thought that it may be somehow caused by not granting the app permission for aforementioned ExternalStorageWrite.

I know that this error gets into the app somewhere after the build, because when I try to control the gpio from the unity editor (pc’s USB “COM4” port) it works perfectly. I am aware that port adress is different when app is deployed on smartphone, so I found this adress using USB Device Info app (/dev/bus/usb/001/002).

Can I be right that this is connected with permissions or do I have to look elsewhere for a solution to this error?

Going to move this thread to one of our Mobile forums, as it’s not an AR problem.