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开发中的异常小工具
最新推荐文章于 2025-12-02 18:54:45 发布
本文介绍了一个用于Android开发的异常处理类,该类能够捕获异常并利用Log输出异常发生的类名、行号及异常信息,有助于开发者快速定位并解决问题。
1652

被折叠的 条评论
为什么被折叠?



