What is toast in Android App Development?
A toast is a small notification message that appears on your device's screen. It provides feedback about an operation and does not take up too much space on the screen. The user can still see and interact with the app while the toast message is displayed. After a short time, the toast message disappears automatically.
For example, when you send an email, a toast message may appear that says "Sending message...". The message is shown next to the app icon on your Android device.
If you are designing an app for Android 12 (API level 31) or higher, your toast messages are limited to two lines of text and must include the application icon next to the text. Keep in mind that the length of the text may vary based on the user's screen size, so it's best to keep the message short and to the point.
Alternatives of "Toast"
If you're creating an app, there are different ways you can display messages to the user. Instead of using a "toast" (a small pop-up message that disappears after a few seconds), consider using a "snackbar" if your app is currently open. Snackbars offer more options for the user and can make for a better app experience.
If your app is running in the background and you want users to take action, use a notification instead.
So, here we have two different options instead of using "Toast"
a.) snackbar and
b.) notification
If you do decide to use a toast, you can create one by using the "makeText()" method and providing the necessary parameters, such as the text to be displayed and how long it should stay on screen. Then, to actually display the toast, use the "show()" method.
How to use toast?
Instantiate a Toast object
Use the makeText() method, which takes the following parameters:
i.) The application Context.
ii.) The text that should appear to the user.
iii.) The duration that the toast should remain on the screen.
The makeText() method returns a properly initialized Toast object.

