Runtime Permission¶
Contents |
Introduction¶
Android permissions can be requested during runtime since Android 6.0 (API 23), however, the requested dialog is shown in 2D. VIVE Wave™ extends the runtime permission service and make it suitable for VR (i.e. showing the requested dialog in 3D).
Note
The permissions that have to be granted should be declared in the AndroidManifest. To declare permissions in AndroidManifest, please refer to Edit -> Project Settings -> Platforms -> Android -> Advanced APK Packagin -> Extra Permissions.
APIs¶
- bool IsPermissionGranted(FString permission)
Return true if the specific permission has already been granted.
- URequestResultObject* RequestPermissions(TArray<FString> permissions)
Checks whether a group of permissions are granted or not. For permissions that have not yet been granted, dialog boxes will be displayed one by one to the user for these permissions to be granted. There are three reasons why the dialog box did not pop up:
- The specific permission has not been declared in the AndroidManifest.
- The specific permission has already been granted.
- The specific permission has been denied with Don’t ask again check box selected.
Moreover, RequestPermissions will return an URequestResultObject which contains a delegate with a permission array and a result array, you can bind this event to know when the user finished all the requests and get the results of the requested permissions.
- bool ShowDialogOnVRScene()
Return true if a requested dialog box will show in 3D while calling RequestPermissions. Return false if the requested dialog box will show in 2D. It should always be true on a VR device.
How to Grant Permissions¶
Please refer to the Level Blueprint of Content/VRTestApp/PermissionManager/PermissionManager_Test.
- Declared permissions that have to be granted by the user in the AndroidManifest.xml. (See the note above in Introduction)
- Collect these permissions in a string array.
- Call IsPermissionGranted to get the permissions which you need user to grant.
- Call RequestPermissions with the array of permission strings.
- The requested dialog box will pop up while calling RequestPermissions, use gaze or controller to Deny or Allow the permission.
- Get granted results from URequestResultObject.