Android Test App perform programming steps backwards

Viewed 66

I am using Delphi Enterprise version 10.2.3 with Android SDK ver 24.3.3 32bit. I tried a very simple program with only one button. The Onclick is simply the following:

ShowMessage('1');
ShowMessage('2');
ShowMessage('3');
ShowMessage('4');

The result I got on my Samsung phone when clicking on the button is:

4
3
2
1

Of course I am expecting to get

1
2
3
4

This is not my first Android Program. The previous ones runs smoothly. But when I got strange errors on my latest program, I found that programming steps are carried out in reverse. I am also scared now to recompile the previous apps, just in case I am getting this strange behavior. So I just make a new program (above) to test, but got the same results. I also disabled the Antivirus Avast program, and even try it on another Samsung device.

Help will be very much appreciated. At this moment I am really confused and not sure what next steps to take to solve the problem. Please help me!

1 Answers

On mobile platforms, ShowMessage behaves asynchronously. The call finishes instantaneously, it does not wait for the user to close the dialog box.

Try this code:

function TForm1.MyShowMessage(const Msg: String): TModalResult;
var
  MR: TModalResult;
begin
  MR := mrNone;
  TDialogService.MessageDialog(Msg, TMsgDlgType.mtConfirmation,const  [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0,
    procedure(const AResult: TModalResult)
    begin
      MR := AResult;
    end);
  while MR = mrNone do begin
    Application.ProcessMessages;
    CheckSynchronize;
  end;
  Result := MR;
end;
Related