How to get around Android permission ACCESS_MEDIA_LOCATION in Unity?
I'm preparing to submit my Quest app but as usual, I'm dealing with getting through Android permission. I get the usual external storage and microphone permissions but those are somewhat easy to find the source by searching for "Microphone." fields in Unity. In fact, most seem to come from Oculus' Platform scripts. The permission that I can't seem to figure out the source is ACCESS_MEDIA_LOCATION. My project doesn't include any external packages nor is attempting to access photos or file metadata. I'm aware that I'm able to remove permissions by hand through Android studio but the issue with this solution is that since I'm not sure where the source of the permission comes from, I'd be open to getting a bug on the app at some point by simply removing this permission. Does anyone know what sorts of classes prompt Unity to add this permission or its source? Are there any solutions other than to simply remove the permission request from the manifest after building the project? Are you having the same issue?Solved6.7KViews1like5CommentsUnable to give permission for All files access
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. I am not able to manipulate the grayed out checkbox with my fingers or controllers. Is there something i did wrong?2.2KViews0likes3CommentsOculus Quest - Need to Dismiss Oculus Menu Bar After Permissions Window Closes
To give some background, Android introduced file storage access restrictions with Android 11. This has presented a problem with some Unity apps I've been working on as they are currently set up to function like so: 1. A launcher app downloads AssetBundles to a particular location on external storage. 2. The launcher app launches another Unity app based on user selection. This app then loads the AssetBundle files from the location that the launcher app downloaded them to. With the new restrictions, this doesn't seem to work at all regardless of where on external storage I try to download the files. Either the launcher app can't download the files there or the launched app doesn't have access to open them. As a workaround I'm using the MANAGE_EXTERNAL_STORAGE permission as detailed here: https://developer.android.com/training/data-storage/manage-all-files I'm aware that this is a restricted permission, but I'm not intending to distribute these apps on the store, so that shouldn't be an issue. Requesting this permission seems to resolve the problem. However, I'm running into an issue with the behavior of this permission window that I'm bringing up. This permission seems function differently than the other Android permissions and I had no luck using Unity's Permissions API to request it. I had to use direct Android calls in order to request the permission properly. Like so: using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject ("currentActivity")) { using (AndroidJavaClass uri = new AndroidJavaClass("android.net.Uri")) { using (AndroidJavaObject intentUri = uri.CallStatic<AndroidJavaObject>("parse", $"package:{Application.identifier}")) { using (AndroidJavaClass settings = new AndroidJavaClass("android.provider.Settings")) { string permission = settings.GetStatic<string>("ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION"); using (AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", permission, intentUri)) { Debug.Log($"AssetLoader - Request storage access permissions..."); _waitingForPermissions = true; currentActivity.Call("startActivity", intent); } } } } } } Unfortunately I can't even really show you what this window looks like because the Quest doesn't seem to capture it properly in either screenshots or video recordings (circled in red where it's supposed to be). The relevant part though is that the Oculus menu bar seems to also appear along with this permissions window as if the user had pressed the Oculus button on the right hand controller (green arrow). Unfortunately, when the user closes the permissions menu, this menu bar is not dismissed along with it. Even though the app seems to regain focus (OnApplicationFocus gets hit with and hasFocus is true) this STILL seems to prevent the user from interacting with the app in any way until they manually hit the Oculus button and resume the background app. I've tried a number of different solutions to try and wrest control back from the Oculus OS such as launching the UnityPlayerActivity again with the FLAG_ACTIVITY_REORDER_TO_FRONT and FLAG_ACTIVITY_CLEAR_TOP intent flags and using startActivityForResult to launch the permissions window and then calling finishActivity in OnApplicationFocus. However this still does not dismiss the menu bar. I've also tried making an Android plugin that serves as a mini activity whose only purpose is to request the permission, but this mini activity runs into the same problem. Has anyone run into this issue when trying to start other android activities from a Unity app? Is there any sort of native call I can make via the Oculus SDK to dismiss this menu myself without the user having to manually do it themselves? I can try bringing up some sort of prompt to tell the user that they have to do so, but it's far from an ideal user experience.1.3KViews3likes0Comments