Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.text.TextUtils; import android.widget.Toast; public class Main { private static Toast sToast; public static void toastMessageLong(Context context, String message) { if (context == null) { return; } if (TextUtils.isEmpty(message)) { sToast = null; return; } if (sToast != null) { sToast.cancel(); sToast = null; } sToast = getToast(context); sToast.setDuration(Toast.LENGTH_LONG); sToast.setText(message); sToast.show(); } private static Toast getToast(Context context) { return Toast.makeText(context, "", Toast.LENGTH_SHORT); } }