show Exception using Toast - Android User Interface

Android examples for User Interface:Toast

Description

show Exception using Toast

Demo Code


//package com.java2s;
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) {/*from  w  ww.jav  a  2  s .  com*/
        e.printStackTrace();

        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