Toast is used to show small text messages on the screen for short time. The toast message stays for about 2, 3, or 5 seconds on screen after that it disappears automatically. The main motive of the toast message is to inform the user such as to warn a user who is trying to enter the number in the name field of the form. There is a dedicated Toast class available in Android SDK to make and show toast messages. The Toast class contains a static method called makeText() that is used to make a toast message. Check out the syntax to create and show a toast message.
Toast.makeText(Context, String message, Toast duration).show();
As in the above syntax, you can clearly see we have used another method called show() to show a toast message on the screen. To mention toast duration static variables LENGTH_SHORT or LENGTH_LONG are available in the Toast class.
Example program to show simple toast message:
Toast.makeText(this, "Hello! This is a Toast message.", Toast.LENGTH_LONG).show()
Parvesh Sandila is a results-driven tech professional with 8+ years of experience in web and mobile development, leadership, and emerging technologies.
After completing his Master’s in Computer Applications (MCA), he began his journey as a programming mentor, guiding 100+ students and helping them build strong foundations in coding. In 2019, he founded Owlbuddy.com, a platform dedicated to providing free, high-quality programming tutorials for aspiring developers.
He then transitioned into a full-time programmer, where his hands-on expertise and problem-solving skills led him to grow into a Team Lead and Technical Project Manager, successfully delivering scalable web and mobile solutions. Today, he works with advanced technologies such as AI systems, RAG architectures, and modern digital solutions, while also collaborating through a strategic partnership with Technobae (UK) to build next-generation products.
