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.

../_images/ExtraPermissions.png

APIs

../_images/APIList.png
  • 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:

  1. The specific permission has not been declared in the AndroidManifest.
  2. The specific permission has already been granted.
  3. 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.

  1. Declared permissions that have to be granted by the user in the AndroidManifest.xml. (See the note above in Introduction)
  2. Collect these permissions in a string array.
  3. Call IsPermissionGranted to get the permissions which you need user to grant.
../_images/IsPermissionGranted.png
  1. Call RequestPermissions with the array of permission strings.
../_images/RequestPermissions.png
  1. The requested dialog box will pop up while calling RequestPermissions, use gaze or controller to Deny or Allow the permission.
  2. Get granted results from URequestResultObject.
../_images/GetResults.png