0

I have the following code in Delphi FMX on Android:

TDialogService.MessageDialog('Test Close message', TMsgDlgType.mtInformation,
                  [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0, nil);

I need to auto-close TDialogService.MessageDialog after 3 seconds.

I tried Screen.MousePos.SetLocation(x, x) for set a tap to simulate.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770

1 Answers1

2

On Android, TDialogService.MessageDialog() simply calls IFMXDialogServiceAsync.MessageDialogAsync() (as Android does not support synchronous dialogs). The default implementation is buried in the TFMXDialogService class in the FMX.Dialogs.Android unit.

You don't have access to the UI dialog it creates, so you can't close it manually. But, what you could do is write your own class that implements the IFMXDialogServiceAsync interface, and then register that class with FMX (you will have to remove the default service first). Then, you can do whatever you want with your dialog implementation. For instance, you could display your own Form that has a timer on it to close the Form.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Doesn't Android limits of showing only one form at a time? That would mean that your suggestion about creating custom form would be out of the question. Since on Android the application is always shown across the whole screen wouldn't it be easier for OP just to use standard components to make something that looks like a message dialog. Then it only needs to show that set of components and bring them on top. Later on he can hide them either by using simple timer or after user clicks on one of the available buttons. ... – SilverWarior Aug 11 '23 at 12:12
  • ... That would work just fine unless OP is using some of the native controls like TWebBrowser since they are always rendered on top of any other controls. – SilverWarior Aug 11 '23 at 12:13