Mastering User Notifications: How to Implement Toasts in Android for Better UX
Most Android apps get feedback wrong in small ways. Not crash-level wrong. Just enough to make the product feel slightly careless — a message that appears at the wrong moment, says something obvious, or vanishes before anyone can read it.
Toasts sit right in the middle of that problem. They look simple. One line of code, a bit of text, done. But in production, the decisions around toasts Android teams make — what to show, where to show it, and whether a toast is even the right tool — affect how polished the app feels far more than most product discussions suggest.
This guide is written from that angle. Not a syntax tutorial. A practical look at how to implement transient notifications well, what Google changed over the years, and where most teams still trip up.
What a Toast Actually Does (and What It Doesn't)
A toast is a short, non-blocking message that appears on screen and disappears on its own. No tap required. No modal interruption. The user keeps working.
That simplicity is both the appeal and the limitation. Toasts are good for lightweight confirmation: item added to cart, settings saved, file copied. They are poor at carrying important information, offering actions, or explaining what went wrong in any detail.
One thing newer developers often miss: a toast is not a notification. It won't appear when your app is in the background. It won't sit in the notification shade. If something happens in a background service and the user isn't actively in your app, a toast is the wrong channel entirely — use a proper notification for that.
Toast vs Snackbar vs Dialog: Picking the Right Pattern
Before writing any code, decide which feedback pattern fits. This is where a lot of apps lose UX quality early on.
- Toast — Brief acknowledgement with no action. "Copied to clipboard." "Profile updated." No buttons, no undo.
- Snackbar — Similar placement and timing, but can include an action ("Undo", "Retry") and follows Material Design behaviour more closely. In most modern apps, this is the better default.
- Dialog — Use when the user must decide something or read something that matters. Destructive actions, permission explanations, multi-step errors.
- Inline feedback — Often overlooked. A red border on a field, a checkmark next to a saved section. Sometimes the best "notification" is no popup at all.
If your message needs a response, don't use a toast. If the user might want to reverse the action, use a Snackbar. If you're only confirming something low-stakes and immediate, a toast still works fine.
Implementing a Basic Toast in Kotlin
The classic API hasn't changed much, though how you should use it has.
Here's a straightforward example in Kotlin:
Toast.makeText(
this,
"Address saved",
Toast.LENGTH_SHORT
).show()
LENGTH_SHORT is roughly two seconds. LENGTH_LONG is closer to three and a half. That's it for duration — you can't fine-tune timing without building something custom, which is usually not worth it.
A few implementation details that matter in real projects:
- Use an Activity context when possible. Passing
applicationContextworks for basic text toasts, but it can behave oddly with custom views and theming. - Don't fire toasts from deep utility layers without thought. If your repository class starts popping toasts on network failure, you'll get duplicate messages, wrong timing, and testing headaches.
- Centralise feedback. A small
UiMessengeror event channel that the UI layer listens to keeps toast logic out of business logic. Cleaner architecture, easier QA.
Why Custom Toasts Are Mostly a Bad Idea Now
Older tutorials — and there are plenty still ranking on Google — show how to inflate a custom XML layout, pass it to toast.setView(), and display a branded popup with icons and colours. That approach made sense years ago. It doesn't anymore.
From Android 11 (API 30) onward, Google restricted custom toast views for apps targeting modern API levels. Custom toasts from background apps are blocked. Even in the foreground, custom toast views are deprecated. The platform wants text-only system toasts for consistency and security — custom overlays were being abused by malware mimicking system UI.
What to do instead:
- Use a Snackbar with a custom layout if you need branded feedback with an action button.
- Use an in-app banner or bottom sheet for richer messaging.
- Stick with plain text toasts for simple confirmations.
If you're maintaining a legacy codebase still using custom toast layouts, plan to migrate. It will break or look inconsistent on newer devices.
Snackbar: The Better Default for Most Teams
For Material-based apps, Snackbar is usually what you actually want. It anchors to a parent view, respects edge-to-edge layouts better, supports action buttons, and feels native on modern Android.
Snackbar.make(binding.root, "Item removed", Snackbar.LENGTH_LONG)
.setAction("Undo") {
viewModel.restoreLastItem()
}
.show()
Notice the difference in capability. The user deletes something, sees confirmation, and can undo — all without a dialog. That's a meaningfully better experience than a toast that just says "Item removed" and leaves the user hoping they didn't make a mistake.
Snackbar also plays nicer with CoordinatorLayout behaviour, swiping, and Material motion. If your team is already using Material Components, default to Snackbar and reserve toasts for the simplest cases.
UX Rules That Actually Matter
Getting the API call right is half the job. The other half is not annoying people.
Don't overuse them
I've reviewed apps that toast on every navigation action, every filter change, every minor save. After the third one in ten seconds, users stop reading. Worse, they start feeling the app is naggy. Toast only when the feedback adds something the UI doesn't already show.
Write human copy
"Operation successful" tells the user almost nothing. "Payment received" or "Couldn't upload photo — try again" is better. Keep it short. If you need a paragraph, it's not a toast.
Time it with user attention
Showing a toast while a keyboard is animating, a bottom sheet is opening, or a loader is visible creates visual noise. Queue feedback or wait until the current transition settles.
Don't stack them
Multiple toasts in quick succession overlap and look broken. Cancel the previous one or debounce messages. A simple in-memory flag or single-channel event handler solves this.
Consider accessibility
Toasts are easy to miss for users with visual impairments. They auto-dismiss, often aren't focusable, and may not be announced reliably by screen readers. For important outcomes, pair a toast with TalkBack-friendly content descriptions or use a Snackbar that meets accessibility guidelines. If the action is critical — payment failure, account lock — use a persistent, accessible UI element.
These details add up. Teams investing in broader Android UX optimisation usually catch toast issues during review rather than after launch, which is exactly where they belong.
Common Mistakes We See in Production Apps
Some patterns come up again and again during code reviews and QA passes.
Showing toasts for errors the user can't act on. "Something went wrong" floating for two seconds and disappearing doesn't help anyone. Point to the problem or offer retry.
Using toasts as debug output. Still happens. A toast on every API response during development that accidentally ships to production is a classic oversight. Use Logcat in debug builds, not user-facing popups.
Triggering toasts from background threads without care. Toast.makeText() should run on the main thread. Wrap it if you're calling from a coroutine or callback that might not be on the UI thread.
Ignoring orientation and foldable changes. A toast shown mid-rotation can flicker or appear in odd positions. Usually minor, but on foldables and tablets it stands out more.
Treating all platforms the same in cross-platform apps. If you're on Flutter or React Native, the toast abstraction may not match native Android behaviour. Test on real devices, not just emulators. Cross-platform teams often discover this late in the cycle — worth flagging early when discussing Android development best practices with your team.
When a Toast Is the Right Call
To be clear, toasts still have a place. Use them when:
- The user triggered a quick action and needs brief confirmation
- No follow-up action is needed
- The success or failure is low stakes
- The rest of the screen already provides enough context
Examples that work well: "Link copied", "Added to wishlist", "Offline — showing saved data". Short, contextual, expected.
Examples that don't: "Your session expired" (needs action), "Upload failed: file exceeds 25MB limit" (too long, needs detail), "New message from Raj" (use notifications).
Building a Simple Feedback Manager
On larger apps, scattering Toast.makeText() calls across fragments and activities becomes hard to maintain. A lightweight feedback manager keeps things consistent.
The idea is simple: one entry point for transient messages. Your ViewModel emits a UiEvent.ShowMessage. The Activity or Fragment collects it and decides whether to show a toast, Snackbar, or something else based on message type and severity.
This also makes it easy to disable toasts during instrumentation tests, swap Snackbars in for toasts app-wide during a redesign, or add analytics — "how often are users seeing error toasts on the checkout screen?" — without hunting through dozens of files.
You don't need a heavy framework for this. A sealed class, a SharedFlow, and one handler in your base activity is enough for most products.
Testing and QA Checklist
Toasts get ignored in test plans because they seem trivial. Then one blocks a button at the wrong moment and suddenly it's a release blocker.
- Verify message text on small screens — does it truncate awkwardly?
- Test rapid repeated actions — do messages pile up?
- Check behaviour with TalkBack enabled
- Confirm no toasts fire when the app is backgrounded
- Test in dark mode and with large font sizes
- Validate that error states use the right component — toast vs Snackbar vs dialog
Small polish items like this separate apps that feel considered from apps that feel assembled. Users may not comment on good feedback patterns, but they absolutely notice bad ones.
Frequently Asked Questions
Are Android toasts deprecated?
setView(). For new development, prefer Snackbar for anything beyond a one-line confirmation.
Can I show a toast from a background service?
Toast or Snackbar — which should I default to?
How do I prevent multiple toasts from stacking?
cancel() before showing a new one, or route all messages through a single event channel that debounces rapid-fire feedback.
Do toasts work well with screen readers?
Conclusion
Implementing toasts in Android is technically easy. Implementing them well is a product decision. The teams that get this right don't treat feedback as an afterthought — they pick the right component for the moment, write clear copy, and respect the user's attention.
If you're starting fresh, use plain text toasts sparingly and reach for Snackbar when an action might help. If you're maintaining older code, audit custom toast layouts and migrate them before they cause inconsistencies on newer Android versions.
None of this is glamorous work. But it's the kind of detail users feel even when they can't name it — and getting it right is one of the quieter ways an app earns trust.
Book a strategy call
From zero-to-one product development to scaling infrastructure. Pinakinvox partners with high-growth teams to solve complex technical challenges.
Recommended by professionals.
Everything published here is tested and deployed in live production systems. No theories.