UncaughtExceptionHandler 问题

UncaughtExceptionHandler issue

在下面的代码中,我在已发布的应用程序中获取异常数据。此应用未 运行 处于调试模式 - 它 运行 作为许多手机上的已发布应用。

我这里的东西工作得很好。它将异常数据放入共享内存中,下次应用程序运行时我将其邮寄给自己。我的问题是我得到的数据不是很有用。这就是生产出来的。 . .

divide by zero StackTrace= [Ljava.lang.StackTraceElement;@7734137 Cause= null ex= java.lang.ArithmeticException: divide by zero

private Thread.UncaughtExceptionHandler onBlooey = new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread thread, Throwable ex) {
                putPref("storedexception", "Exception: " + ex);
        }
};   

这告诉我的不多。无论如何我可以获得堆栈跟踪?有什么能告诉我错误发生在程序中的什么地方吗? 谢谢, 院长

糟糕。发布到 很快。找出答案...

    private Thread.UncaughtExceptionHandler onBlooey = new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread thread, Throwable ex) {
                // quickly store the exception info and mail it to me nextime on startup
            debugLog("found uncaught exception: " + ex, true);
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            String st = "";
            st = sw.toString(); // stack trace as a string
            putPref("storedexception", "Exception: " + ex + " stacktrace: " + st);
        }
};