private void CheckMicPermission() { try { if (!(PermissionsHelper.HasPermission(this, ConstantsAndTypes.AppPermission.UseMicrophone) && PermissionsHelper.PermissionGranted(this, ConstantsAndTypes.AppPermission.UseMicrophone))) { AttemptPermissionRequest(); } } catch (Exception e) { Log.Error(TAG, "CheckMicPermission: Exception - " + e.Message); ErrorDisplay.ShowErrorAlert(this, e, "Checking Microphone permission", "StructuredPlanFantasiesDialogActivity.CheckMicPermission"); } }
private void CheckMicPermission() { try { if (!(PermissionsHelper.HasPermission(Activity, ConstantsAndTypes.AppPermission.UseMicrophone) && PermissionsHelper.PermissionGranted(Activity, ConstantsAndTypes.AppPermission.UseMicrophone))) { Toast.MakeText(Activity, Resource.String.MicrophonePermissionDenialToast, ToastLength.Short).Show(); if (_recordAudioButton != null) { _recordAudioButton.Enabled = false; } } } catch (Exception e) { Log.Error(TAG, "CheckMicPermission: Exception - " + e.Message); ErrorDisplay.ShowErrorAlert(Activity, e, "Checking Microphone permission", "VoiceRecordingDialogFragment.CheckMicPermission"); } }
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults) { base.OnRequestPermissionsResult(requestCode, permissions, grantResults); try { if (requestCode == ConstantsAndTypes.REQUEST_CODE_PERMISSION_USE_MICROPHONE) { if (grantResults.Length > 0 && grantResults[0] == Permission.Granted) { //now update the global permission if (GlobalData.ApplicationPermissions == null) { //if null then we can go get permissions PermissionsHelper.SetupDefaultPermissionList(this); } else { //we need to update the existing permission if (PermissionsHelper.HasPermission(this, ConstantsAndTypes.AppPermission.UseMicrophone)) { GlobalData.ApplicationPermissions.Find(perm => perm.ApplicationPermission == ConstantsAndTypes.AppPermission.UseMicrophone).PermissionGranted = Permission.Granted; } } PermissionResultUpdate(Permission.Granted); } else { PermissionResultUpdate(Permission.Denied); Toast.MakeText(this, Resource.String.MicrophonePermissionDenialToast, ToastLength.Short).Show(); } } } catch (Exception e) { Log.Error(TAG, "OnRequestPermissionsResult: Exception - " + e.Message); ErrorDisplay.ShowErrorAlert(this, e, "Processing permission result", "StructuredPlanRelationshipsDialogActivity.OnRequestPermissionsResult"); } }