Android Toast Example

Android lets you "toast" a display message that pops up on top of the current window. This usually occurs on some condition and is generally simple in nature, something like "OK", or "File submitted", etc. The code below can be plugged into any android class to launch a toast.

    Toast toast = Toast.makeText(getApplicationContext(), "Invalid Parameter", Toast.LENGTH_SHORT);;

This bit of code will launch a short toast that displays the text "Invalid Parameter". The length of the toast is 2 seconds, and can be changed to a longer 3.5 second toast by changing the duration(Toast.LENGTH_SHORT) to Toast.LENGTH_LONG.

Toast away!