show Exception in AlertDialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

show Exception in AlertDialog

Demo Code


//package com.java2s;

import android.app.AlertDialog;
import android.content.Context;
import android.util.Log;

public class Main {
    public static void showException(Context parent, Throwable ex) {
        if (ex != null) {
            Log.e(parent.getClass().getSimpleName(),
                    ex.getLocalizedMessage(), ex);
            new AlertDialog.Builder(parent).setTitle("Error")
                    .setMessage(ex.getLocalizedMessage())
                    .setNeutralButton("Close", null).show();
        }//from   www. ja va2  s  .  com
    }
}

Related Tutorials