Delphi Non-Blocking MessageDialog Example How?

2.8k views Asked by At

I have problem using FMX.Platform.IFMXDialogServiceAsync

This is my procedure:

procedure TFormMain.btnLogoutClick(Sender: TObject);
var
  ASyncService : IFMXDialogServiceASync;

begin

  ASyncService.MessageDialogAsync('Do you want to logout?', TMsgDlgType.mtInformation,
    [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo],
    TMsgDlgBtn.mbNo,
    0,
    procedure(const AResult: TModalResult)
    begin
      case AResult of
      mrYes:
        begin
          Close;
        end;
      mrNo:
        begin
        // pressed no
        end;
      end;
    end
  );

end;

Below is Error that Pop-up:

Access violation at address
A29FC4F2, accessing address
00000000.

Tried directly into Android Device and Error show whenever this procedure triggered. Looked to Embarcadero Documentation but they didn't provide an example for this.

Someone written some example that I use above http://c2design5sh.blogspot.co.id/2016/05/rad-studio-dx-101-berlin-dialog-api.html

Is there anyone can tell on how to do new way MessageDialog in Android?, because I found MessageDlg going deprecated.

1

There are 1 answers

0
David Heffernan On

You simply need to use the code in the article you linked to. You failed to do so. The example code has this form:

var
  ASyncService : IFMXDialogServiceASync;
....
if TPlatformServices.Current.SupportsPlatformService(IFMXDialogServiceAsync, IInterface (ASyncService)) then
begin
  ASyncService.MessageDialogAsync(....);
end;

Your code fails to assign to the ASyncService variable. Hence the runtime error.