Home > Enterprise >  Camera permission in delphi 11
Camera permission in delphi 11

Time:02-20

I am trying to acquire the image through the camera of the android device, with actionList, I always get the following error. Where am I wrong?

Here my code:

 procedure TMain.BtnTakePhotoClick(Sender: TObject);
  var
  Service: IFMXCameraService;
  Params : TParamsPhotoQuery;
 begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXCameraService,Service) then
  begin
    Params.Editable := True;
    // Specifies whether to save a picture to device Photo Library
    Params.NeedSaveToAlbum := True;
    Params.RequiredResolution := TSize.Create(640, 640);
    Params.OnDidFinishTaking := TakePhotoFromCameraAction1DidFinishTaking;
    Service.TakePhoto(BtnTakePhoto, Params);
  end
  else
    ShowMessage('This device does not support the camera service');
 end;

OnformCreate Permission:

procedure TMain.FormCreate(Sender: TObject);
 var
  VCam, VRead, VWrite: string;
begin
  // Request permissions
  VCam := JStringToString(TJManifest_permission.JavaClass.CAMERA);
  VRead := JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE);
  VWrite := JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE);
  PermissionsService.RequestPermissions([VCam, VRead, VWrite], PermissionRequestResult, DisplayRationale);
end;
 
      
I always receive: There is no overloaded version of 'RequestPermission'.
Waht i'm doing wrong?
Thank you.

CodePudding user response:

You've probably used the old declarations, like this is fine:

PROCEDURE PermissionRequestResult(             Sender : TObject;
                                  const APermissions  : TClassicStringDynArray;
                                  const AGrantResults : TClassicPermissionStatusDynArray);

PROCEDURE DisplayRationale(      Sender             : TObject;
                           const APermissions       : TClassicStringDynArray;
                           const APostRationaleProc : TProc);
  • Related