} finally {
if (defaultUncaughtExceptionHandler != null) {
defaultUncaughtExceptionHandler.uncaughtException(t, e);
}
}
}
private File dealException(Thread thread, Throwable throwable) throws JSONException, IOException, PackageManager.NameNotFoundException {
String time = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(new Date());
//私有目录,无需权限
File f = new File(context.getExternalCacheDir().getAbsoluteFile(), “crash_info”);
if (!f.exists()) {
f.mkdirs();
}
File crashFile = new File(f, time + FILE_NAME_SUFFIX);
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(crashFile)));
pw.println(time);
pw.println("Thread: " + thread.getName());
pw.println(getPhoneInfo());
throwable.printStackTrace(pw); //写入crash堆栈
pw.flush();
pw.close();
return crashFile;
}
pr