All Products
Search
Document Center

Mobile Platform as a Service:Toast notification

Last Updated:Jan 23, 2026

AUToast is a component for displaying toast notifications on a page. AUProgressDialog is a component for displaying progress indicators.

When you call the toast method from BaseFragmentActivity or BaseActivity, the mPaaS framework automatically customizes the toast notifications.

Activities that use BaseFragmentActivity and BaseActivity use AUToast by default.

Dependencies

For more information, see Getting started.

API reference

    /**
     * Instantiates a Toast.
     *
     * @param context    The context. Use the activity of the current page.
     * @param drawableId The image resource.
     * @param tipSrcId   The ID of the text message.
     * @param duration   The display duration. Toast.LONG or Toast.SHORT.
     * @return A Toast object.
     */
    public static Toast makeToast(Context context, int drawableId, int tipSrcId, int duration) {
        CharSequence tipSrc = context.getResources().getText(tipSrcId);
        return makeToast(context, drawableId, tipSrc, duration);
    }

    /**
     * Creates a Toast.
     *
     * @param context  The context. Use the activity of the current page.
     * @param tipSrcId The message to show.
     * @param duration The duration.
     * @return A toast object.
     */
    public static Toast makeToast(Context context, int tipSrcId, int duration) {
        CharSequence tipSrc = context.getResources().getText(tipSrcId);
        return makeToast(context, 0, tipSrc, duration);
    }

    /**
     * Makes a toast that contains an image view and a text view.
     *
     * @param context    The context. Use the activity of the current page.
     * @param drawableId The image resource ID.
     * @param tipSrc     The text to show. Can be formatted text.
     * @param duration   How long to display the message. Either Toast.LONG or Toast.SHORT.
     * @return A Toast object.
     */
    public static Toast makeToast(Context context, int drawableId, CharSequence tipSrc, int duration)

Code example

    // Success
        AUToast.makeToast(ToastActivity.this, com.alipay.mobile.antui.R.drawable.toast_ok, "Success notification", Toast.LENGTH_SHORT).show();


    // Failure
        AUToast.makeToast(ToastActivity.this, com.alipay.mobile.antui.R.drawable.toast_false, "Failure notification", Toast.LENGTH_SHORT).show();
    }

    // Warning
        AUToast.makeToast(ToastActivity.this, com.alipay.mobile.antui.R.drawable.toast_warn, "Warning notification", Toast.LENGTH_SHORT).show();
    }

    // Text
        AUToast.showToastWithSuper(ToastActivity.this, 0, "The text cannot exceed 14 characters.", Toast.LENGTH_SHORT);

    // Loading
    AUProgressDialog dialog = new AUProgressDialog(this);
    dialog.setMessage("Loading...");
    dialog.show();

}