Jump to content
kaarigar

Async dialog on android?

Recommended Posts

uses
  FMX.DialogService.Async;

procedure TestAsyncDlg;
begin
  TDialogServiceAsync.MessageDialog('Hello Android!',
             TMsgDlgType.mtInformation,
             [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0);
end;

 

  • Like 1

Share this post


Link to post
1 hour ago, corneliusdavid said:

uses
  FMX.DialogService.Async;

procedure TestAsyncDlg;
begin
  TDialogServiceAsync.MessageDialog('Hello Android!',
             TMsgDlgType.mtInformation,
             [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0);
end;

 

This code shows async dialog. I need sync or modal dialog on android. Documentation says that the modal dialogs are not supported on android and was looking for a work around way or technique to have it on android.

Share this post


Link to post
3 hours ago, kaarigar said:

This code shows async dialog. I need sync or modal dialog on android

Uh, both the subject of this thread and your original question specifically asked for async dialogs:

On 1/15/2022 at 11:42 AM, kaarigar said:

Is there any way to have async dialogs on android platform?

So I guess I'll let someone else try and answer your question.

  • Like 2

Share this post


Link to post

 

3 hours ago, kaarigar said:

Documentation says that the modal dialogs are not supported on android

There's a good reason for that - implementing modal dialogs on Android the same way as on Windows is practically impossible.

3 hours ago, kaarigar said:

and was looking for a work around way or technique to have it on android

The workaround is to use async dialogs. Developers do this on Windows all the time - from one form, show another. When the user takes some action on the secondary form, do something based on that action, and close the form. The primary form will still be there when they get back 🙂 

 

If the primary form needs to "know" what happened on the secondary form, you could expose a property or event handler on the secondary form which the primary form can examine, or handle.

  • Like 1

Share this post


Link to post
21 minutes ago, Dave Nottage said:

 

There's a good reason for that - implementing modal dialogs on Android the same way as on Windows is practically impossible.

The workaround is to use async dialogs. Developers do this on Windows all the time - from one form, show another. When the user takes some action on the secondary form, do something based on that action, and close the form. The primary form will still be there when they get back 🙂 

 

If the primary form needs to "know" what happened on the secondary form, you could expose a property or event handler on the secondary form which the primary form can examine, or handle.

Thanks for the suggestion. I have been using forms for this purpose as you suggest on Windows platform. I will do the same in this case too - but I was curious because sync dialogs are supported on other platforms.

 

Btw, I gave wrong subject heading to my post - it should have been “Modal dialogs in android”, and not async dialog. Sorry  for the confusion.

Share this post


Link to post
6 hours ago, corneliusdavid said:

uses
  FMX.DialogService.Async;

procedure TestAsyncDlg;
begin
  TDialogServiceAsync.MessageDialog('Hello Android!',
             TMsgDlgType.mtInformation,
             [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0);
end;

 

My apologies - your response is perfect for the question I asked. However I made a mistake in typing - I was really interested in modal dialogs - which are sync dialogs. I was confused at the time of posting and I must have confused you!

Share this post


Link to post
9 minutes ago, kaarigar said:

I was curious because sync dialogs are supported on other platforms.

I can understand that async dialogs are a concept that can be a challenge to embrace. Some time in the future we'll all be wondering why 😉

 

  • Like 1

Share this post


Link to post

For FMX to support something like "modal" dialogs the compiler needs to support something like Async, Await, but currentlt it doesn't, for example, I can show a dialog in Flutter and waith for the result with code like this:

 

var data = await showDialogAndWaithForAnswer();

// do something with data later.

 

Meanwhile, the current solution for FMX makes the developer to change the logic and way of programming for one that is not as good as the one we are acustomed.

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×