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); } }
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); } }
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; } }