Android Toast Create showToastInThread(final Context context, final String msg)

Here you can find the source of showToastInThread(final Context context, final String msg)

Description

show Toast In Thread

Declaration

public static void showToastInThread(final Context context,
            final String msg) 

Method Source Code

//package com.java2s;
import android.content.Context;

import android.os.Handler;
import android.os.Looper;

import android.widget.Toast;

public class Main {
    public static void showToastInThread(final Context context,
            final String msg) {
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            public void run() {
                showToast(context, msg);
            }// w w  w  . j a  v a2  s  .co  m
        });
    }

    public static void showToast(Context context, String msg) {
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    }
}

Related

  1. showToast(final Context context, final int resId)
  2. showToast(final Context ctx, final Handler handler, final String text, final int duration)
  3. showToast(final Context ctx, final Handler handler, final int id, final int duration)
  4. showToast(final String toast, final Context context)
  5. showToast(final String toast, final Context context)
  6. toast(String message, Context context)
  7. toast(final Context context, final CharSequence msg)
  8. msgLong(Context context, String msg)
  9. msgLong(final Context c, final String msg)