package com.example.datalibrary.utils; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.widget.Toast; public class ToastUtils { private static Handler handler = new Handler(Looper.getMainLooper()); public static void toast(final Context context, final String text) { handler.post(new Runnable() { @Override public void run() { Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); } }); } public static void toast(final Context context, final int resId) { handler.post(new Runnable() { @Override public void run() { Toast.makeText(context, resId, Toast.LENGTH_SHORT).show(); } }); } }