1

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.

2
  • 2
    You're using a variable that is not initialized. You just declare a variable ASyncService to exist in your method. Then you use it without assigning something to it first. You should stick to your tutorial more closely. And yes, the compiler doesn't even bother telling you that your code is wrong, which is pretty sad. Commented Dec 19, 2016 at 8:32
  • you right!, I removed that "if" because I don't think it was necessary, thanks!!!, its solved! Commented Dec 19, 2016 at 10:11

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.