show Exception using Toast - Android android.widget

Android examples for android.widget:Toast

Description

show Exception using Toast

Demo Code

import android.app.Activity;
import android.util.Log;
import android.widget.Toast;

public class Main {

  private static final String TAG = "ActivityUtil";

  public static void showException(Activity activity, String msg, Throwable e) {
    e.printStackTrace();//from w  w w  .  j a  v a 2 s.  c o  m

    String s = String.format("%s: %s", msg, e.getMessage());
    showToast(activity, s);
    Log.e(TAG, s);
  }

  public static void showToast(Activity activity, String msg) {
    String s = String.format("animator: %s", msg);
    Toast.makeText(activity, s, Toast.LENGTH_LONG).show();
  }

}

Related Tutorials