O'Reilly logo

Android Development Tools for Eclipse by Sanjay Shah, Khirulnizam Abd Rahman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Toast message

This is one of the common practices to pop-up a message box for notifying the user. This kind of notification is a type of notification that does not require a user answer or feedback.

Toast.makeText(this.getApplicationContext(), hellomsg,
         Toast.LENGTH_SHORT).show();

Toast.makeText() contains three parameters which are the application context, the message and the time length.

  • The application context is the current screen to display the message
  • The message is the string to be displayed
  • The time length is consisting of a short or longer duration of the message display and has to be one of Toast.LENGTH_* constants

The arrow in the following screenshot is pointing to a Toast:

Example of a Toast

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required