| | |
| | | */ |
| | | @Override |
| | | public void uncaughtException(Thread thread, Throwable ex) { |
| | | Log.i(TAG, "uncaughtException Throwable:"+ex); |
| | | //Log.i(TAG, "uncaughtException Throwable:"+ex); |
| | | if (!handleException(ex) && mDefaultHandler != null) { |
| | | //如果用户没有处理则让系统默认的异常处理器来处理 |
| | | mDefaultHandler.uncaughtException(thread, ex); |
| | |
| | | * @return true:如果处理了该异常信息;否则返回false. |
| | | */ |
| | | private boolean handleException(Throwable ex) { |
| | | Log.i(TAG, "handleException Throwable:"+ex); |
| | | //Log.i(TAG, "handleException Throwable:"+ex); |
| | | if (ex == null) { |
| | | return false; |
| | | } |
| | |
| | | * @return 返回文件名称,便于将文件传送到服务器 |
| | | */ |
| | | private String saveCatchInfoFile(Throwable ex) { |
| | | ex.printStackTrace(); |
| | | Log.i(TAG, "saveCatchInfo2File Throwable:"+ex); |
| | | //ex.printStackTrace(); |
| | | //Log.i(TAG, "saveCatchInfo2File Throwable:"+ex); |
| | | |
| | | StringBuffer sb = new StringBuffer(); |
| | | for (Map.Entry<String, String> entry : infos.entrySet()) { |
| | |
| | | |
| | | Writer writer = new StringWriter(); |
| | | PrintWriter printWriter = new PrintWriter(writer); |
| | | ex.printStackTrace(printWriter); |
| | | //ex.printStackTrace(printWriter); |
| | | Throwable cause = ex.getCause(); |
| | | while (cause != null) { |
| | | cause.printStackTrace(printWriter); |
| | | //cause.printStackTrace(printWriter); |
| | | cause = cause.getCause(); |
| | | } |
| | | printWriter.close(); |
| | |
| | | s = reader.readLine(); |
| | | if(s == null) break; |
| | | //由于目前尚未确定以何种方式发送,所以先打出log日志。 |
| | | Log.i("info", s.toString()); |
| | | //Log.i("info", s.toString()); |
| | | } |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |