Skip to content


Pfennigbaum edited this page Jun 11, 2015 · 22 revisions



SuperActivityToasts are made to replace stock Android Toasts that are used in an Activity Context.
SuperActivityToasts attach themselves to the activity's content and will not linger from activity to activity.
SuperActivityToasts can have buttons, progressbars, and icons.


SuperActivityToasts should be used wherever an Activity context is available.
SuperActivityToasts can NOT be used in a non-Activity context.


  1. Customization options such as background color, font, text size, animation etc.
  2. Duration can be any millisecond value.
  3. An icon can be displayed along with the SuperActivityToast.
  4. SuperActivityToasts can recieve onClick() events.
  5. Touch to dismiss function.
  6. Four variations.
  7. Orientation change support


Below you will find code examples for the different types of SuperActivityToasts.


NOTE: Standard SuperActivityToasts are default, if a type is not specified your SuperActivityToast will be the standard type.

Static method to create and show a standard SuperActivityToast.

SuperActivityToast.create(Activity.this, "Hello world!", SuperToast.Duration.LONG).show();

Static method to create and show a standard SuperActivityToast with a specified pre-set style.

SuperActivityToast.create(Activity.this, "Hello world!",
    SuperToast.Duration.SHORT, Style.getStyle(Style.BLUE, SuperToast.Animations.FLYIN)).show();

New SuperActivityToast object styled via methods and will dismiss if the user touches it.

SuperActivityToast superActivityToast = new SuperActivityToast(Activity.this);
superActivityToast.setText("Hello world!");


IMPORTANT: Progress SuperActivityToasts will NOT recreate on orientation change, this should be managed by the developer similar to a ProgressDialog.

New SuperActivityToast object with an indeterminate duration and progressbar.

SuperActivityToast superActivityToast = new SuperActivityToast(Activity.this, SuperToast.Type.PROGRESS);
superActivityToast.setText("Hello world!");

Progress Horizontal

IMPORTANT: Progress Horizontal SuperActivityToasts will NOT recreate on orientation change, this should be managed by the developer similar to a ProgressDialog.

New SuperActivityToast object with an indeterminate duration and progressbar with set progress.

SuperActivityToast superActivityToast = new SuperActivityToast(Activity.this, SuperToast.Type.PROGRESS_HORIZONTAL);
superActivityToast.setText("Hello world!");


New SuperActivityToast object that resembles the undo delete bar in Gmail app.

SuperActivityToast superActivityToast = new SuperActivityToast(Activity.this, SuperToast.Type.BUTTON);
superActivityToast.setText("Some action performed.");
superActivityToast.setButtonIcon(SuperToast.Icon.Dark.UNDO, "UNDO");

 * The OnClickWrapper is needed to reattach SuperToast.OnClickListeners on orientation changes. 
 * It does this via a unique String tag defined in the first parameter so each OnClickWrapper's tag 
 * should be unique.
OnClickWrapper onClickWrapper = new OnClickWrapper("superactivitytoast", new SuperToast.OnClickListener() {

    public void onClick(View view, Parcelable token) {

        /* On click event */



Orientation change support

To have SuperActivityToasts retain themselves on orientation change you must implement the following code.

Save state

IMPORTANT: If you do not call this method you may have lingering SuperActivityToasts when a new Activity is started on top of a showing SuperActivityToast.

Add the following to your Activity, this will save the SuperActivityToast that is showing along with any others in the queue.

protected void onSaveInstanceState(Bundle outState) {



Restore state

IMPORTANT: If you have used any OnClickWrappers or OnDismissWrappers you must use the second method.

Add this restore method to the onCreate of your Activity, this will recreate and show any SuperActivityToasts showing or pending before the orientation change.

SuperActivityToast.onRestoreState(savedInstanceState, Activity.this);

If you are using any OnClickWrappers or OnDismissWrapers you must create a new Wrappers object, add any OnClickWrappers or OnDismissWrapers you used to the Wrappers object, and pass the Wrappers object as a parameter. This reattaches them to the appropriate SuperActivityToasts.

Wrappers wrappers = new Wrappers();
SuperActivityToast.onRestoreState(savedInstanceState, Activity.this, wrappers);
You can’t perform that action at this time.