感谢Randy的建议,我用一个类似的旧代码将异常记录到一个文件中(我尝试使用运行时的exec,但它只产生一个空文件)。
这里是我使用的代码:
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
File logFile = new File("/any/directory/logFile.log");
PrintWriter out = null;
try{
if(!logFile.exists()){
try {
if(!logFile.createNewFile())
Log.e(TAG, "Some error creating log file " + logFile.getAbsolutePath());
} catch (IOException ex) {
Log.e(TAG, "IoException creating logFile: " + ex.getMessage());
ex.printStackTrace();
}
}
out = new PrintWriter(new BufferedWriter(new FileWriter(logFile, true)));
out.println(
new SimpleDateFormat("yyyy-MM-dd_hh:mm:ss.SSS", Locale.getDefault()).format(new Date()) + "\t" +
TAG + "\t" +
"Thread " + t + " throws exception: " + e
);
if(e != null)
e.printStackTrace(out);
out.flush();
} catch (IOException ex) {
Log.e(TAG, "IoException writing logFile: " + ex.getMessage());
ex.printStackTrace();
} finally {
if(out != null)
out.close();
}
});
}
尝试解决你(让'adb'司机的工作)的实际问题,而不是建立新的 –
我已经在努力解决这个问题,我已经打开了另一个爱普生支持的线程。我问这是因为我正在寻找解决方法。无论如何,为什么downvote? – ocramot