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.9KViews1like5CommentsUnable 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.4KViews0likes3CommentsHow to remove Android permissions in Unreal Engine?
Android12GooglePlayFix plugin doesn't seem to work I added (xmlns:tools="http://schemas.android.com/tools") to the "extra tags for <manifest> node" slot, and made a new 'ManifestRequirementsOverride.txt' file in MyProject/Build/Android which seems to get ignored This is my manifest in Intermediate/Android <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.UNLAWFUL.Applab" android:installLocation="auto" android:versionCode="2" android:versionName="0.5"> <queries> <intent> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> </intent> <intent> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" /> </intent> </queries> <!-- Application Definition --> <application android:label="@string/app_name" android:icon="@drawable/icon" android:allowBackup="False" android:usesCleartextTraffic="False" android:hardwareAccelerated="true" android:extractNativeLibs="true" android:name="com.epicgames.ue4.GameApplication" android:requestLegacyExternalStorage="true" android:hasCode="true"> <activity android:name="com.epicgames.ue4.GameActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:configChanges="mcc|mnc|uiMode|density|screenSize|smallestScreenSize|screenLayout|orientation|keyboardHidden|keyboard" android:resizeableActivity="false" android:launchMode="singleTask" android:screenOrientation="landscape" android:excludeFromRecents="true" android:taskAffinity="" android:debuggable="true"> <meta-data android:name="android.app.lib_name" android:value="UE4" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="com.oculus.intent.category.VR" /> </intent-filter> <meta-data android:name="com.oculus.vr.focusaware" android:value="true" /> </activity> <activity android:name=".DownloaderActivity" /> <meta-data android:name="com.epicgames.ue4.GameActivity.EngineVersion" android:value="4.27.2" /> <meta-data android:name="com.epicgames.ue4.GameActivity.EngineBranch" android:value="++UE4+Release-4.27" /> <meta-data android:name="com.epicgames.ue4.GameActivity.ProjectVersion" android:value="1" /> <meta-data android:name="com.epicgames.ue4.GameActivity.DepthBufferPreference" android:value="0" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bPackageDataInsideApk" android:value="true" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bVerifyOBBOnStartUp" android:value="false" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bShouldHideUI" android:value="true" /> <meta-data android:name="com.epicgames.ue4.GameActivity.ProjectName" android:value="March" /> <meta-data android:name="com.epicgames.ue4.GameActivity.AppType" android:value="" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bHasOBBFiles" android:value="true" /> <meta-data android:name="com.epicgames.ue4.GameActivity.BuildConfiguration" android:value="Shipping" /> <meta-data android:name="com.epicgames.ue4.GameActivity.CookedFlavors" android:value="ASTC" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bValidateTextureFormats" android:value="true" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bUseExternalFilesDir" android:value="false" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bPublicLogFiles" android:value="false" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bUseDisplayCutout" android:value="false" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bAllowIMU" android:value="true" /> <meta-data android:name="com.epicgames.ue4.GameActivity.bSupportsVulkan" android:value="true" /> <meta-data android:name="com.epicgames.ue4.GameActivity.StartupPermissions" android:value="android.permission.WRITE_EXTERNAL_STORAGE" /> <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> <service android:name="OBBDownloaderService" /> <receiver android:name="AlarmReceiver" /> <receiver android:name="com.epicgames.ue4.LocalNotificationReceiver" /> <receiver android:name="com.epicgames.ue4.MulticastBroadcastReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> <meta-data android:name="android.max_aspect" android:value="2.10" /> <meta-data android:name="com.oculus.supportedDevices" android:value="quest|delmar" /> </application> <!-- Requirements --> <uses-feature android:glEsVersion="0x00030001" android:required="true" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="com.android.vending.CHECK_LICENSE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="com.android.vending.BILLING" /> <!-- Supported texture compression formats (cooked) --> <supports-gl-texture android:name="GL_KHR_texture_compression_astc_ldr" /> <uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-feature android:name="android.hardware.usb.host" /> </manifest>836Views0likes0CommentsCannot launch OpenXR game from other 2D activity or apps, Transitions fails and XR game crashes
Original issue: I am trying to create a normal 2D app to let the user perform some operations that are much easier to be maintained and handled in a Java/Kotlin app. Like fetch data and choosing some options, login and acquire a token, get location and etc. Then I want to send the user to an NativeActivity which starts OpenXR session and immersive part of the user experience starts. Unfortunately I can not start the native activity from the Kotlin code using Intents and startActivity. I managed to see the immersive mode for a sec but then it crashes shortly after creating XR session. I figured that there might be extra complications having native and Kotlin activities in the same app or issues in my OpenXR app itself, so I tried a simpler approach that can be reproduced easily to get help. Simplified Issue, easy to reproduce: I have `XrSpaceWarp` sample from Oculus OpenXRSDK. No change to manifest-xml or the code, It works on it's own and I can run it via `adb` : adb shell am start -n com.oculus.sdk.xrspacewarp/android.app.NativeActivity Then I have a simple android app from project templates of AndroidStudio, and on click event of a button I create an Intent and try to launch the XrSpaceWarp example. val myIntent: Intent? = this.packageManager.getLaunchIntentForPackage("com.oculus.sdk.xrspacewarp"); // Or alternatively //val myIntent = Intent(Intent.ACTION_MAIN) //myIntent.setComponent(ComponentName("com.oculus.sdk.xrspacewarp", "android.app.NativeActivity")) // Also tried setting all and some combination of the flags if (myIntent != null) { myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) myIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) } try { startActivity(myIntent) } catch (e: ActivityNotFoundException) { Log.d("dummy_app", "starting activity failed") } Then the XrSpaceWarp app starts and I can see the scene (yellow floating cubes) for half a second, and then it crashes. The manifest of the XrSpaceWarp sample app is: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.oculus.sdk.xrspacewarp" android:versionCode="1" android:versionName="1.0" android:installLocation="auto" > <!-- Tell the system this app requires OpenGL ES 3.1. --> <uses-feature android:glEsVersion="0x00030001" android:required="true"/> <uses-feature android:name="android.hardware.vr.headtracking" android:required="true" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- Volume Control --> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <application android:allowBackup="false" android:label="xrspacewarp" android:hasCode="false"> <meta-data android:name="com.oculus.supportedDevices" android:value="all" /> <!-- The activity is the built-in NativeActivity framework class. --> <!-- launchMode is set to singleTask because there should never be multiple copies of the app running. --> <!-- Theme.Black.NoTitleBar.Fullscreen gives solid black instead of a (bad stereoscopic) gradient on app transition. --> <!-- If targeting API level 24+, configChanges should additionally include 'density'. --> <!-- If targeting API level 24+, android:resizeableActivity="false" should be added. --> <activity android:name="android.app.NativeActivity" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:launchMode="singleTask" android:screenOrientation="landscape" android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"> <!-- Tell NativeActivity the name of the .so --> <meta-data android:name="android.app.lib_name" android:value="xrspacewarp" /> <!-- This filter lets the apk show up as a launchable icon. --> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="com.oculus.intent.category.VR" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> I have tried this with different flags, adding more intent filters in the XR app with other actions than MAIN and categories and also other apps (like other games on the headset that I installed from the store) and same thing happens. I can see the other activity starts and also the XR-session and GLES context and everything, but it can not maintain the focus and the session. There are some permission errors I can see in all cases: VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS TREX com.oculus.sdk.xrspacewarp E Interface version 3 was not found. Check debug build for more information. VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS InputDispatcher system_server E But another display has a focused window FocusedWindows: displayId=0, name='4af4f2f Shell.EventInterceptor' VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS VrDeviceManagerService vrdevicemanagerserver E Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS OVRMediaServiceManager com.oculus.horizon E LivestreamingManager Not initialized OVRMediaServiceManager com.oculus.horizon E LivestreamingManager Not initialized OVRMediaServiceManager com.oculus.horizon E LivestreamingManager Not initialized OsSdk com.oculus.sdk.xrspacewarp E error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'requested shared memory region when not registered/focused' OsSdk com.oculus.sdk.xrspacewarp E error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'requested shared memory region when not registered/focused' OsSdk com.oculus.sdk.xrspacewarp E error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled' OsSdk com.oculus.sdk.xrspacewarp E error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled' OsSdk com.oculus.sdk.xrspacewarp E error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled' OsSdk com.oculus.sdk.xrspacewarp E error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled' AnalyticsEvent com...us.identitymanagement.service E could not set key=selection_args value=null QplClient com.oculus.systemux:SystemUX E com.oculus.systemux: init() called multiple times. QplClient com.oculus.systemux:SystemUX E com.oculus.systemux: init() called multiple times. XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: r = xrPollEvent(app->Instance, &eventDataBuffer): ??_t XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySwapchain(frameBuffer->ColorSwapChain.Handle): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorSwapChain.Handle): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorDepthSwapChain.Handle): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySwapchain(frameBuffer->ColorSwapChain.Handle): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorSwapChain.Handle): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorDepthSwapChain.Handle): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySwapchain(scene->QuadSwapChain.Handle): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySpace(appState.HeadSpace): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySpace(appState.LocalSpace): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySpace(appState.FakeStageSpace): XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroySession(appState.Session): `-Jt OpenXR-Loader com.oculus.sdk.xrspacewarp E Error [GENERAL | xrDestroyInstance | OpenXR-Loader] : Instance handle is XR_NULL_HANDLE. XrSpaceWarp com.oculus.sdk.xrspacewarp E OpenXR error: xrDestroyInstance(appState.Instance): oyInstance BpTransact...edListener surfaceflinger E Failed to transact (-32) I have tried the same thing with AndroidStudio's template projects of Native activity and Native GameActivity (that draws some simple android logo with OpenGL) and they work, so its definitely not because its a native activity or trouble with GL context, its the Immersive mode causing the problem and the fact that I am starting it from a 2D app. I would apricate if someone could help me to make this solution work or share their experience. Is it even possible to switch to OpenXR app from a 2D app at all?4.7KViews1like5CommentsAndroid Permission Request Screen Text Not Appearing
We are using a less common Android permission request (REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) in order to support downloading multiple large 360 videos to the Quest 2 (total ~30GB). This permission request appears in a different UI to the standard permissions, and we are finding that it only appears correctly approx 50% of the time. The other 50% of the time the permission prompt background appears, but without the text or buttons. This is causing issues as without accepting this permission, our downloads will fail. Looks like this when text doesn't appear: Should look like this: Given the size of the download, the user will take the headset off whilst the download completes. We require this permission in order to prevent the device from entering doze or app standby and killing the app/download manager. There is no error or log message shown in logcat when the dialogue does not display correctly. We’ve attempted various methods of requesting this permission and it still only appears 50% of the time. It also seems to open the Oculus Dashboard menu, so the app can’t be interacted with until the Oculus button is pressed to close the dash. Ideally, we'd like it to appear in the standard permissions screen shown below, or to appear in the current UI but with the text showing every time. Any ideas?1KViews1like0CommentsOculus 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.3KViews3likes0CommentsMicrophone permission prompt not showing up
I am developing on Quest 2. I am using the Agora RTC SDK which would access the microphone for voice input. I specified the permission in the AndroidManifest.xml file, and also ask it in the Unity code for access. However, the prompt isn't showing up on Quest 2 like it did on other Android devices. Is there something missing here? How does the others voice related app do this?1KViews2likes0Comments