Einzelnen Beitrag anzeigen

philipp.hofmann

Registriert seit: 21. Mär 2012
Ort: Hannover
861 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: LocationSensor Crash Android64

  Alt 1. Feb 2022, 11:58
Bei mir ist es umgekehrt, mit jeder Delphi-Version wird es besser. Ich frage die Permissions seit Delphi 11 folgendermaßen ab:

Delphi-Quellcode:
{$IFDEF ANDROID}
procedure TfTibbleBox.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
    mlog.info('User granted Location-Android-permission');
  end else begin
    mlog.info('Not all Location-Android-permission granted (' + IntToStr(length(AGrantResults)) + ')');
    for i:=0 to length(AGrantResults) - 1 do
    begin
      if (AGrantResults[i] = TPermissionStatus.Granted) then
        mlog.info(IntToStr(i) + ': granted')
      else
        mlog.info(IntToStr(i) + ': not granted');
    end;
  end;
end;

procedure TfTibbleBox.requestLocationPermissions();
begin
  if (not requestedLocationPermissions) then
  begin
    requestedLocationPermissions:=true;
    mlog.info('Request Location-Permission for Android');
    PermissionsService.RequestPermissions(['android.permission.ACCESS_COARSE_LOCATION', 'android.permission.ACCESS_FINE_LOCATION'], LocationPermissionRequestResult);
  end;
end;
{$ENDIF}
  Mit Zitat antworten Zitat