public static void AskForPermission(Activity activity, string[] permissions, IPermissionCalback permissionCallback) { if (permissionCallback is null) { return; } if (HasPermission(activity, permissions)) { permissionCallback.PermissionGranted(); } var request = new PermissionRequest(permissions.ToList(), permissionCallback); _permissionRequests.Add(request); activity.RequestPermissions(permissions, request.RequestCode); }
public static void OnRequestPermissionsResult(int reqCode, Permission[] grantResults) { var req = new PermissionRequest(reqCode); if (_permissionRequests.Contains(req)) { if (VerifyPermissions(grantResults)) { req.PermissionCalback.PermissionGranted(); } else { req.PermissionCalback.PermissionDenied(); } _permissionRequests.Remove(req); } RefreshMonitoredList(); }