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 when gravity >=0.
  • yoffset β€” set this parameter only when gravity >=0.
okay so real talk on xoffset and yoffset: they only make sense when gravity >=0. if you're out here passing -1 for 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