0

Building an Android app with Delphi 11.3, I'd like to ask more than one user permission, explaining to the user why he needs to give me this permissions. Using this code in a DataModule:

procedure SetPermissions();
const
  Explanation : string = 'you have to...';
begin
  TDialogService.MessageDialog(Explanation, TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0,
    procedure(const AResult: TModalResult)
    begin
      PermissionsService.RequestPermissions(Permissions,
        procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>)
        begin
          if (Length(AGrantResults) > 0) and (AGrantResults[0] = TPermissionStatus.Granted) then
          begin
            // permission granted
          end
          else
          begin
            // permission not granted
          end;
        end
      );
    end
  );
end;

It seems clear to me, simple and correct, but the compiler still says:

[DCC Error] udmMain.pas(287): E2250 There is no overloaded version of 'RequestPermissions' that can be called with these arguments
[DCC Error] udmMain.pas(289): E2250 There is no overloaded version of 'MessageDialog' that can be called with these arguments

I can't understand why! Please help me.

4
  • 1
    Delphi 11.3 has changed the function header. In requestpermissions you have to use TClassicStringDynArray and TClassicPermissionStatusDynArray instead of TArray<string> and TArray<TPermissionStatus> May 29 at 16:51
  • 1
    Didn't you ask the same question before one year ago? May 29 at 16:53
  • Yes you're right, that method worked but not well in a 11.3 but thank you for this suggestion perhaps i was in panic! I have corrected as you said and it works, also i would like to show a message to user and i was not able to do this only if the permission are not granted. May 29 at 17:25
  • You should ask for the permission without using the messagedialog and move the messagedialog into the "no permission granted" section May 30 at 11:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.