'There is no overloaded version of 'RequestPermissions' that can be called with these arguments giving more then one permisssion
with Delphi 10 i used a procedure to give android app multiple permissions on a onCreate Event:
var
permBatt, permRead, permWrite, permBlue, permAccess, permCoarse: string;
begin
{$IFDEF ANDROID}
// Request permissions
permBatt := JStringToString(TJManifest_permission.JavaClass.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
permRead := JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE);
permWrite := JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE);
permBlue := JStringToString(TJManifest_permission.JavaClass.BLUETOOTH);
permAccess := JStringToString(TJManifest_permission.JavaClass.ACCESS_FINE_LOCATION);
permCoarse := JStringToString(TJManifest_permission.JavaClass.ACCESS_COARSE_LOCATION);
PermissionsService.RequestPermissions([permBatt, permRead, permWrite, permBlue, permAccess, permCoarse], PermissionRequestResult);
{$ENDIF}
now in delphi 11 Alexandria I receive a compiler error
[DCC Error] data.main.pas(237): E2250 There is no overloaded version of 'RequestPermissions' that can be called with these arguments
I tried use the new singnature of PermissionService.RequestPermission passing a procedure as a paramether and using the new Delphi constants:
const
permBatt = 'android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS';
permRead = 'android.permission.READ_EXTERNAL_STORAGE';
permWrite = 'android.permission.WRITE_EXTERNAL_STORAGE';
permBlue = 'android.permission.BLUETOOTH';
permAccess = 'android.permission.ACCESS_FINE_LOCATION';
permCoarse = 'android.permission.ACCESS_COARSE_LOCATION';
{$IFDEF ANDROID}
PermissionsService.RequestPermissions([permBatt, permRead, permWrite, permBlue, permAccess, permCoarse ],
procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>)
begin
if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then
TDialogService.ShowMessage('OK permessi')
else
begin
TDialogService.ShowMessage('Location permission not granted');
end;
end);
{$ENDIF}
but the error is still there, any idea? Thank you so moutch
Solution 1:[1]
I found the right solution and i hope it'll help
procedure TMainData.DataModuleCreate(Sender: TObject);
const
permBatt = 'android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS';
permRead = 'android.permission.READ_EXTERNAL_STORAGE';
permWrite = 'android.permission.WRITE_EXTERNAL_STORAGE';
permBlue = 'android.permission.BLUETOOTH';
permAccess = 'android.permission.ACCESS_FINE_LOCATION';
permCoarse = 'android.permission.ACCESS_COARSE_LOCATION';
begin
{$IFDEF ANDROID}
PermissionsService.RequestPermissions([permBatt,permRead, permWrite, permBlue, permAccess, permCoarse],
procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray)
begin
if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then
{ activate or deactivate the location sensor }
else
begin
TDialogService.ShowMessage('Devi dare il permesso alla localizzazione esplicitamente');
end;
end);
{$ENDIF}
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Franz Andreani |
