Jump to content
Sign in to follow this  
Delpher2600

Code for getting permissions not working in Delphi 11

Recommended Posts

Hello! 

Code, which i used for getting Android permissions, worked every time:

if not PermissionsService.IsPermissionGranted(JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE)) then
PermissionsService.RequestPermissions([JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE)],
procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>)
begin
if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then
ShowMessage('Access granted')
else
ShowMessage('Access denied');
end);

But no now, when i installed Delphi 11 CE. Now, IDE highlights by red and write: 

E2250 There is no overloaded version of 'RequestPermissions' that can be called with these arguments at line 36

What is it and how fix it? 

 

Share this post


Link to post

This:

procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>)

Needs to be:

procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray)

I believe the change to the types was related to C++Builder compatibility

  • Like 2

Share this post


Link to post
7 hours ago, Dave Nottage said:

I believe the change to the types was related to C++Builder compatibility

This looks like the tail wagging the dog. 

Share this post


Link to post
17 hours ago, Dave Nottage said:

This:


procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>)

Needs to be:


procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray)

Yes, that's work! Thank you, sir!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×