红鱼儿

CCAMap的定位方法增加权限请求
procedure TCCAMap.StartLocation();
begin

{$IFDEF ANDROID}
  PermissionsService.RequestPermissions([JStringToString(TJManifest_permission.JavaClass.ACCESS_COARSE_LOCATION),
                                         JStringToString(TJManifest_permission.JavaClass.ACCESS_FINE_LOCATION),
                                         JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE),
                                         JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE)
                                        ],
{$IF CompilerVersion >= 35} // Delphi 11
    procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray)
{$ELSE}
  procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>)
{$ENDIF}
  begin
    if (Length(AGrantResults) = 4) and
       (AGrantResults[0] = TPermissionStatus.Granted) and
       (AGrantResults[1] = TPermissionStatus.Granted) and
       (AGrantResults[2] = TPermissionStatus.Granted) and
       (AGrantResults[3] = TPermissionStatus.Granted) then
    begin
      // 必须有读写权限再初始化.
      FJAMap.StartLocation;
    end;
  end);
{$ENDIF}

end;

 

posted on 2024-12-13 14:43  红鱼儿  阅读(18)  评论(0编辑  收藏  举报