Java tutorial
//package com.java2s; import android.content.Context; import android.support.annotation.StringRes; import android.text.TextUtils; import android.widget.Toast; public class Main { public static void showLong(Context context, String msg) { if (context != null && !TextUtils.isEmpty(msg)) { Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_LONG).show(); } } public static void showLong(Context context, @StringRes int resId) { if (context != null) { Toast.makeText(context.getApplicationContext(), resId, Toast.LENGTH_LONG).show(); } } }