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

Delphi XE5 Firemonkey Android ToastIf 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:

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.

Pop Up Toast Like Info Messages With Delphi XE5 Firemonkey On Android And IOS by Delphi XE5 XE6 XE7 XE8 10 Seattle Berlin Firemonkey, Delphi Android, Delphi IOS is licensed under a Creative Commons Attribution 4.0 International License.

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

  1. Brian Hamilton says:

    works great, thanks for sharing 🙂

  2. Roland Kossow says:

    You can find a crossplattform toast like component here …

    https://www.cybertribe.de/info/components/fmx/toast/

    Best regards

    Roland

  3. Roland Kossow says:

    To be precise – Paul Thornton created the repository …
    https://code.google.com/p/fmx-extensions/source/browse/trunk/?r=5#trunk%2FLib%2FAPI … but the native toast code is from Brian Long ( http://blog.blong.com/ ) and the unit FMX.AndroidLike.Toast.pas is coded by me.

    See for a new version of the toast like component with an improved interface and a fancy component icon 😉
    https://www.cybertribe.de/info/components/fmx/toast/

    • Godfrey says:

      I cannot get the toast component to work. Keeps asking for FMX.AndroidLike.Toast.dcu. I have put the path into the Libary path.

      The strange thing is it works when I select Win32 as the target but when I select Android it give above error.

      Can someone help. Thanks

      • Could it be that you did not add the path for the case of Android Build Target or that you did not recompile?

        • Godfrey says:

          Not sure how/where to do this?

          • Godfrey says:

            Sorry my message did not come out how I wanted it.
            Not sure how/where to add the path for the case of Android Build Target

          • Tools/Options/Delphi Options/Library Path & Searchpath.
            Above the options you can see a combobox labeled something like “Selected Platform” – be sure to select Android there before adding the paths.

            (Descriptions may vary since I do not have my IDE in English at the moment.)

          • Godfrey says:

            Thanks. I did not see that you had to set the path for each platform.
            One suggestion. Can I suggest a property “WordWrap” which is linked to the “OptimalWidth”. At the
            moment it wraps the text which does not always look so good.

          • Yes – good idea – I put it on the ToDo list.

          • Tools/Options/Delphi Options/Library Path & Searchpath.
            Above the options you can see a combobox labeled something like “Selected Platform” – be sure to select Android there before adding the paths.

            (Descriptions may vary since I do not have my IDE in English at the moment.)

    • Eduardo says:

      Roland,

      I am using your Toast unit, thanks to implement it. Why dont you create a repository for it also?

      There are 2 issues on the component right now:

      – I am using it as a large band in the middle of the window, It works fine, however after the timer event is fired and it gets “closed” actually the rectangle remains there, and consumes all the mouse clicks. I thought I was suffering another FMX bug then I realized was the Toast area. I believe using small rectangles you did not noticed that.
      – The other problem is that for unknown reason in one of my projects I removed the component and replaced it again, and since there is a tabcontrol with animation to switch pages the toast rectangle is anchored in one of the pages and I see it passing by when the page is animated for change. I dont understand why, since I have another exact copy of this project where I did not remove the component and the Toast message is on the form level.

      If you could fix that bug when closing the rectangle I would appreciate much. Just put a TEdit and open a Toast over it and you can see the problem after closing. You cannot select the TEdit anymore.

      Thanks !

  4. Godfreys suggestion to have a wordwrap property has been imlemented …

    https://www.cybertribe.de/druid/index.php?q=de/node/85

    … for download of FMXToast.zip

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Delphi XE5 Firemonkey Android Shortcut
Install Shortcuts On The Android Home Screen With Delphi XE5 Firemonkey

If you are building a professional Android application with Delphi XE5 Firemonkey one thing you will want to do is...

Close