在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'