How to use toast

satya - Saturday, May 15, 2010 1:41:37 PM

sample


//define a class level local variable first
Toast mToast;


//some time later do something like this

// Tell the user about what we did.
if (mToast != null) {
   mToast.cancel();
}
mToast = Toast.makeText(AlarmController.this, 
         R.string.repeating_unscheduled,
         Toast.LENGTH_LONG);

mToast.show();

satya - Monday, August 16, 2010 5:07:42 PM

Toast API ref

Toast API ref

satya - Monday, August 16, 2010 5:10:58 PM

Goal

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, appears as a floating view over the application. It will never receive focus. The user will probably be in the middle of typing something else. The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see. Two examples are the volume control, and the brief message saying that your settings have been saved. The easiest way to use this class is to call one of the static methods that constructs everything you need and returns a new Toast object.

satya - Friday, August 20, 2010 2:54:35 PM

cancel

in the previous code the "cancel" seem to be there to not show the previous message or stop showing if shown. If this is not a requirement then it doesn't need to be used.

Calls to toast seem to work even if done repeatedly in the main thread one after the other, like sending debug messages from a menu response.

satya - Wed Aug 22 2012 15:46:13 GMT-0400 (Eastern Daylight Time)

Understand toast more...

Understand toast more...