cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to give permission for All files access

dextro007
Honored Guest

I am currently working on an application that uses a specific document on the users device to transfer information and records between itself and different simmilar applications made by my team (imagine Game A storing its highscores in a shared document so Game B can read those same highscores and incorporate them in Game B).

This methodologie allready works on the Hololens 2 which i have also developed for so i assumed it would work on the Quest 3 aswell. After doing some research i discovered that my best bet would be to try to get All File Access letting me access a shared directory between my different games.

I found some code online that should help me ask for All Files Permission Access, as that isnt natively supported by unity itself.

using var buildVersion = new AndroidJavaClass("android.os.Build$VERSION");
using var buildCodes = new AndroidJavaClass("android.os.Build$VERSION_CODES");

//Check SDK version > 29
if (buildVersion.GetStatic<int>("SDK_INT") > buildCodes.GetStatic<int>("Q"))
{
    using var environment = new AndroidJavaClass("android.os.Environment");
    //сhecking if permission already exists
    if (!environment.CallStatic<bool>("isExternalStorageManager"))
    {
        using var settings = new AndroidJavaClass("android.provider.Settings");
        using var uri = new AndroidJavaClass("android.net.Uri");
        using var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        using var currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
        using var parsedUri = uri.CallStatic<AndroidJavaObject>("parse", $"package:{Application.identifier}");
        using var intent = new AndroidJavaObject("android.content.Intent",
            settings.GetStatic<string>("ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION"),
            parsedUri);
        currentActivity.Call("startActivity", intent);
        return true;
    }
}
return false;

However after trying to ask for permission i am presented with the following screen. 

PermissionRequestFailure.png

I am not able to manipulate the grayed out checkbox with my fingers or controllers. Is there something i did wrong?

1 REPLY 1

dextro007
Honored Guest

I seem to have found my solution!

For anyone else struggeling with this problem, make sure you add :

	<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

to the AndroidManifest.xml file.