Registriert seit: 8. Feb 2008
Ort: Bremen
96 Beiträge
Delphi 11 Alexandria
|
AW: Android-RequestPermissions unter Delphi 11 (keine überladene Version)
2. Nov 2021, 14:21
Delphi-Quellcode:
procedure TicTrainerF.requestBLEPermissions();
begin
if (requestedBLEPermissions) then
exit;
PermissionsService.RequestPermissions(['android.permission.ACCESS_COARSE_LOCATION', 'android.permission.ACCESS_FINE_LOCATION'], LocationPermissionRequestResult);
end;
// Delphi 10.x
//procedure LocationPermissionRequestResult(Sender: TObject; const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>);
// Delphi 11
procedure LocationPermissionRequestResult(Sender: TObject; const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray);
var i: Integer;
begin
if ((length(AGrantResults) = 2) and (AGrantResults[0] = TPermissionStatus.Granted) and (AGrantResults[1] = TPermissionStatus.Granted)) then
begin
log.d('User granted Location-Android-permission for BLE', True);
requestedBLEPermissions:=True;
end else begin
log.d('Not all Location-Android-permission for BLE granted (' + IntToStr(length(AGrantResults)) + ')', True);
for i:=0 to length(AGrantResults) - 1 do
begin
if (AGrantResults[i] = TPermissionStatus.Granted) then
log.d(IntToStr(i) + ': granted', True)
else
log.d(IntToStr(i) + ': not granted', True)
end;
end;
end;
So sollte es funktionieren.
|
|
Zitat
|