public void AskForPermission(string permission, int requestCode, IPermissionCallback callback)
 {
     currentPermissionCallback = callback;
     var permissionCheck = (int)ContextCompat.CheckSelfPermission(this, permission);
     if (permissionCheck == (int)Permission.Granted)
     {
         callback.OnGrantedPermission(requestCode);
     }
     else
     {
         currentRequestCodePermission = requestCode;
         ActivityCompat.RequestPermissions(this, new string[] { permission }, requestCode);
     }
 }
Пример #2
0
        public void AskForPermission(string permission, int requestCode, IPermissionCallback callback)
        {
            currentPermissionCallback = callback;
            var permissionCheck = (int)ContextCompat.CheckSelfPermission(this, permission);

            if (permissionCheck == (int)Permission.Granted)
            {
                callback.OnGrantedPermission(requestCode);
            }
            else
            {
                currentRequestCodePermission = requestCode;
                ActivityCompat.RequestPermissions(this, new string[] { permission }, requestCode);
            }
        }
Пример #3
0
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
 {
     if (requestCode == currentRequestCodePermission)
     {
         if (grantResults.Length > 0 && grantResults[0] == Permission.Granted)
         {
             // permission was granted
             if (currentPermissionCallback != null)
             {
                 currentPermissionCallback.OnGrantedPermission(requestCode);
             }
         }
         else
         {
             // permission denied
             if (currentPermissionCallback != null)
             {
                 currentPermissionCallback.OnDeniedPermission(requestCode);
             }
         }
         currentPermissionCallback = null;
     }
 }
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
 {
     if (requestCode == currentRequestCodePermission)
     {
         if (grantResults.Length > 0 && grantResults[0] == Permission.Granted)
         {
             // permission was granted
             if (currentPermissionCallback != null)
             {
                 currentPermissionCallback.OnGrantedPermission(requestCode);
             }
         }
         else
         {
             // permission denied
             if (currentPermissionCallback != null)
             {
                 currentPermissionCallback.OnDeniedPermission(requestCode);
             }
         }
         currentPermissionCallback = null;
     }
 }