Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOS

Pop Up Toast Like Info Messages With Delphi XE5 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE5 Firemonkey Android Toast | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSIf you have an info level event that you want to notify the user about in Delphi XE5 Firemonkey but you don’t need the user to click an Okay button about it the Android Toast messages might be what you’re looking for. You can launch a Toast to display something like ‘Low Battery’ or ‘Low Memory’ to the user. You are notifying the user of the event without disturbing their usage of your app. As you can see in the screenshot the Toast message pops up in a rectangle on the screen. Usually it fades in and then fades about again. Toast is a native Android feature but there is some code I found which will also give you a similar message system in your IOS apps. These two units are from Delphi developer Paul Thornton. Here is some code from the Android.JNI.Toast.pas unit:
{$IFDEF ANDROID}

uses
FMX.Helpers.Android;

procedure Toast(const Msg: string; duration: TToastLength);
var
ToastLength: Integer;
begin
if duration = ShortToast then
ToastLength := TJToast.JavaClass.LENGTH_SHORT
else
ToastLength := TJToast.JavaClass.LENGTH_LONG;
CallInUiThread(
procedure
begin
TJToast.JavaClass.makeText(SharedActivityContext, StrToJCharSequence(Msg),
ToastLength).show
end);
end;
{$ENDIF}

You can also access the Toast API using the DPF for Android suite of Delphi Firemonkey components.

Check out the source for the Toast API and the Toast like cross platform messages on Google Code.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

18 Comments

Leave a Reply