在Android开发中,当程序发生异常时会抛出异常信息,可以通过如下代码来获取异常信息,然而在ANR时我们在Logcat中并看不到异常信息。
Thread.setDefaultUncaughtExceptionHandler(new Thread.
UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
System.out.println(t + " throws exception: " + e);
}
});
I/art: Thread[2,tid=25238,WaitingInMainSignalCatcherLoop,Thread*=0xafa0e400,peer=0x12c2a080,"Signal Catcher"]: reacting to signal 3
I/art: Wrote stack traces to '/data/anr/traces.txt'