Forum Discussion
phil.tvr
2 years agoHonored Guest
Oculus 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.
Replies have been turned off for this discussion
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago
- 8 months ago