Android examples for User Interface:Toast
show Message using Toast via WeakReference
//package com.java2s; import android.content.Context; import android.widget.Toast; import java.lang.ref.WeakReference; public class Main { public static void showMessage(Context context, String message) { WeakReference<Context> contextWeakReference = new WeakReference<Context>( context);/* w w w.j a v a2s.c om*/ Toast.makeText(contextWeakReference.get(), message, Toast.LENGTH_SHORT).show(); } }