Java tutorial
//package com.java2s; import android.content.Context; import android.widget.Toast; public class Main { public static void toastMsg(Context context, String msg, int duration) { if (context != null) Toast.makeText(context, msg, duration).show(); } public static void toastMsg(Context context, int resId, int duration) { if (context != null) Toast.makeText(context, context.getResources().getString(resId), duration).show(); } }