Back to project page android-util.
The source code is released under:
Apache License
If you think the Android project android-util listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ms.square.android.util; //from ww w. j a v a2 s . c o m import android.content.Context; import android.view.Gravity; import android.widget.Toast; /** * This class prevents multiple toasts from being queued. */ public final class ToastMaster { private static Toast sToast = null; private ToastMaster() { } public static void setToast(Toast toast) { if (sToast != null) { sToast.cancel(); } sToast = toast; } public static void cancelToast() { if (sToast != null) { sToast.cancel(); } sToast = null; } public static void showToast(Context context, String msg, int display_length) { Toast toast = Toast.makeText(context, msg, display_length); toast.setGravity(Gravity.BOTTOM, 0, 0); // displays in the bottom of the screen ToastMaster.setToast(toast); toast.show(); } }