// Return a list of file sources that are used for finding books. public List <string> getSources() { // Request any permissions required to access the file system. switch (SelectController.getActivePlatform()) { case SelectController.DeviceOptions.Daydream: #if UNITY_ANDROID string permission = "android.permission.READ_EXTERNAL_STORAGE"; GvrPermissionsRequester permissionRequester = GvrPermissionsRequester.Instance; if (permissionRequester != null) { if (!permissionRequester.IsPermissionGranted(permission)) { permissionRequester.ShouldShowRational(permission); permissionRequester.RequestPermissions(new string [] { permission }, (GvrPermissionsRequester.PermissionStatus [] permissionResults) => { foreach (GvrPermissionsRequester.PermissionStatus p in permissionResults) { Debug.Log("Req perm " + p.Name + ": " + (p.Granted ? "Granted" : "Denied") + "\n"); } }); bool granted = permissionRequester.IsPermissionGranted(permission); } } #endif break; case SelectController.DeviceOptions.OculusGo: case SelectController.DeviceOptions.OculusQuest: #if UNITY_ANDROID if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead)) { Permission.RequestUserPermission(Permission.ExternalStorageRead); } #endif break; default: break; } if (knownSources == null) { // #if PLATFORM_ANDROID // if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead)) // { // Permission.RequestUserPermission(Permission.ExternalStorageRead); // } // #endif prepareSources(); } return(knownSources); }
private void RequestMicrophone() { GvrPermissionsRequester permissionRequester = GvrPermissionsRequester.Instance; if (permissionRequester?.IsPermissionGranted(PERMISSION_NAME) ?? false) { permissionRequester.RequestPermissions(new string[] { PERMISSION_NAME }, permissionStatuses => { foreach (var permissionStatus in permissionStatuses) { _hasPermission = permissionStatus.Granted; } }); } }
public void CheckPermission() { statusText.text = "Checking permission..."; GvrPermissionsRequester permissionRequester = GvrPermissionsRequester.Instance; if (permissionRequester != null) { bool granted = permissionRequester.IsPermissionGranted(permissionNames[0]); statusText.text = permissionNames[0] + ": " + (granted ? "Granted" : "Denied"); } else { statusText.text = "Permission requester cannot be initialized."; } }
/// <summary> /// Checks whether all necessary external permissions have been granted and informs user of /// the current state. /// </summary> public void CheckPermission() { Debug.Log("Checking permission...."); GvrPermissionsRequester permissionRequester = GvrPermissionsRequester.Instance; if (permissionRequester != null) { bool granted = permissionRequester.IsPermissionGranted(permissionNames[0]); Debug.Log(permissionNames[0] + ": " + (granted ? "Granted" : "Denied")); } else { Debug.Log("Permission requester cannot be initialized."); } }
/// <summary> /// Checks external permissions requirements and current permissions granted. /// </summary> /// <remarks> /// Prompts user with requests for outstanding needed permissions, and informs them of the /// current state. /// </remarks> public void RequestPermissions() { if (statusText != null) { statusText.text = "Requesting permission...."; } GvrPermissionsRequester permissionRequester = GvrPermissionsRequester.Instance; if (permissionRequester == null) { statusText.text = "Permission requester cannot be initialized."; return; } Debug.Log("Permissions.RequestPermisions: Check if permission has been granted"); if (!permissionRequester.IsPermissionGranted(permissionNames[0])) { Debug.Log("Permissions.RequestPermisions: Permission has not been previously " + "granted"); if (permissionRequester.ShouldShowRational(permissionNames[0])) { statusText.text = "This game needs to access external storage. Please grant " + "permission when prompted."; statusText.color = Color.red; } permissionRequester.RequestPermissions(permissionNames, (GvrPermissionsRequester.PermissionStatus[] permissionResults) => { statusText.color = Color.cyan; permissionList.Clear(); permissionList.AddRange(permissionResults); string msg = ""; foreach (GvrPermissionsRequester.PermissionStatus p in permissionList) { msg += p.Name + ": " + (p.Granted ? "Granted" : "Denied") + "\n"; } statusText.text = msg; }); } else { statusText.text = "ExternalStorage permission already granted!"; } }
/// <summary> /// Checks external permissions requirements and current permissions granted. /// </summary> /// <remarks> /// Prompts user with requests for outstanding needed permissions, and informs them of the /// current state. /// </remarks> public void RequestPermissions() { Debug.Log("Requesting permission...."); GvrPermissionsRequester permissionRequester = GvrPermissionsRequester.Instance; if (permissionRequester == null) { Debug.Log("Permission requester cannot be initialized."); return; } Debug.Log("Permissions.RequestPermisions: Check if permission has been granted"); if (!permissionRequester.IsPermissionGranted(permissionNames[0])) { Debug.Log("Permissions.RequestPermisions: Permission has not been previously " + "granted"); permissionRequester.RequestPermissions(permissionNames, (GvrPermissionsRequester.PermissionStatus[] permissionResults) => { permissionList.Clear(); permissionList.AddRange(permissionResults); string msg = ""; foreach (GvrPermissionsRequester.PermissionStatus p in permissionList) { msg += p.Name + ": " + (p.Granted ? "Granted" : "Denied") + "\n"; } Debug.Log(msg); }); } else { Debug.Log("Permission already granted!"); } }