Toast message in Android

Darshana Chorat
1 min readJun 19, 2020

--

What is Toast in Android?

A toast is a view containing a quick little message for the user. The toast class helps you create and show those.

When the view is shown to the user, it appears as a floating view over the application.
The best example is to save the contact, and the message saying that Contact saved. Another type of Toast is custom Toast, in which images can be used instead of a simple message.

Create Toast

The below example demonstrates everything you need for most toast notifications. You should rarely need anything else like positioning a toast message and creating your own toast layout instead of simple toast. The following sections describe how you can do these things.

Note: I am using the Kotlin programming language.

Syntax

Toast.makeText(context, text, duration).show()

Example

Toast.makeText(applicationContext,"Hello",Toast.LENGTH_LONG).show()

You can find the additional documentation on the official Android Developers page.

If you like the article please don't forget to👏 clap and share it with friends. In case if you find any mistake please mention that in the comment. Stay tuned for more AndroidDev blogs.

Happy Coding😊

Team CodingWithDarshana

--

--