SDL_ShowAndroidToast(3)
π SDL_ShowAndroidToast π
okay bestie, so this is a page from the SDL3 functions manual, and today's main character is SDL_ShowAndroidToast β she shows an Android toast notification. yes, literally a toast. no, not the bread kind (sadly). πβ¨
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_system.h>
bool SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset);
like, that's the whole vibe. one function, five args, she's doing a lot with very little. π
β¨ DESCRIPTION β¨
So toasts are this whole thing that's unique to Android β they're a sort of lightweight notification. very low-key, very demure, they pop up, they say their piece, they leave. π¦
Here's the official lore, straight from the source, no cap:
https://developer.android.com/guide/topics/ui/notifiers/toasts
She shows the toast in the UI thread. periodt. π
And for the gravity parameter? You gotta pick a value from here, or use -1 if you genuinely do not have a preference and you're just letting the universe decide:
https://developer.android.com/reference/android/view/Gravity
π FUNCTION PARAMETERS π
messageβ the text message that's gonna be shown. this is what everyone's gonna read, so make it cute.durationβ0=short,1=long. that's it, that's the whole scale, two options, pick one bestie.gravityβ where the notification should appear on the screen. location, location, location. πxoffsetβ set this parameter only whengravity >=0.yoffsetβ set this parameter only whengravity >=0.
okay so real talk onxoffsetandyoffset: they only make sense whengravity >=0. if you're out here passing-1for gravity, those offsets are not your moment. π
π RETURN VALUE π
Returns true on success or false on failure β and if it's a flop, call SDL_GetError() for more information. she will tell you what went wrong, you just have to ask. π
π«Ά THREAD SAFETY π«Ά
It is safe to call this function from any thread. go wild, queen. no notes. π₯
β AVAILABILITY β
This function is available since SDL 3.2.0. so if you're on anything older... that's giving ancient history, bestie. π
π reminder that this is an Android-only situation. toasts are a whole Android thing. iykyk.
and that's the page!! brought to you by the lovely humans over at Simple Directmedia Layer, running SDL 3.4.18 β mwah, thank you for your service, this documentation ate and left no crumbs π§ππΈ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms