package com.zzl.tools; import android.util.Log; public class Tool { /** * android开发中的异常处理类,如有异常用log输出 * Tag:ExceptionLocation * class:发生异常的类 * LineNumber:出现的异常位于哪一行, * info:异常信息,即什么异常。 */ public static void getExceptionLineNumberAndInfo(Exception e) { StackTraceElement[] trace = e.getStackTrace(); if (trace == null || trace.length == 0){ }else{ //System.out.println("ExceptionLocation :"+"class="+trace[0].getClassName()+";LineNumber="+trace[0].getLineNumber()+" "+e.toString()); Log.i("ExceptionLocation", "class="+trace[0].getClassName()+";LineNumber="+trace[0].getLineNumber()+" ;info: "+e.toString()); } } }
android开发中的异常小工具
猜你喜欢
转载自android-zhang.iteye.com/blog/1821197
今日推荐
周排行