5
A
回答
6
日誌收集器的源代碼在Google Code上可用。他們實際上只是調用logcat。在這裏看到:android-log-collector - SendLogActivity.java
這裏是關鍵部分:
ArrayList<String> commandLine = new ArrayList<String>();
commandLine.add("logcat");//$NON-NLS-1$
commandLine.add("-d");//$NON-NLS-1$
ArrayList<String> arguments = ((params != null) && (params.length > 0)) ? params[0] : null;
if (null != arguments){
commandLine.addAll(arguments);
}
Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0]));
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null){
log.append(line);
log.append(App.LINE_SEPARATOR);
}
0
你可以使用內置的錯誤報告系統。 http://blog.tomtasche.at/2012/10/use-built-in-feedback-mechanism-on.html
ApplicationErrorReport report = new ApplicationErrorReport();
report.packageName = report.processName = getApplication()
.getPackageName();
report.time = System.currentTimeMillis();
report.type = ApplicationErrorReport.TYPE_CRASH;
report.systemApp = false;
ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
crash.exceptionClassName = e.getClass().getSimpleName();
crash.exceptionMessage = e.getMessage();
StringWriter writer = new StringWriter();
PrintWriter printer = new PrintWriter(writer);
e.printStackTrace(printer);
crash.stackTrace = writer.toString();
StackTraceElement stack = e.getStackTrace()[0];
crash.throwClassName = stack.getClassName();
crash.throwFileName = stack.getFileName();
crash.throwLineNumber = stack.getLineNumber();
crash.throwMethodName = stack.getMethodName();
report.crashInfo = crash;
Intent intent = new Intent(Intent.ACTION_APP_ERROR);
intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
startActivity(intent);
+0
[這是關於Meta上這些帖子的討論](http ://meta.stackexchange.com/q/153352/152134) – 2012-11-01 21:48:31
相關問題
- 1. 如何在Redhat中獲取系統日誌文件
- 2. Android文件系統日誌記錄
- 3. Python系統日誌文件
- 4. 使用PHP讀取系統日誌
- 5. 如何使用系統日誌獲取perl stderr到httpd日誌文件
- 6. android系統和日誌
- 7. FastMM4,如何讀取日誌文件?
- 8. 從文件系統中讀取文件
- 9. 如何在C++中讀取這個日誌文本文件
- 10. R如何導入日誌文件系統json文件?
- 11. 無法讀取遠程系統事件日誌
- 12. 如何從Java程序獲取Android系統日誌
- 13. Ubuntu:大系統日誌和kern.log文件
- 14. 追蹤日誌文件系統
- 15. 獲取系統日誌在果凍豆
- 16. 在Android上閱讀系統文件
- 17. 如何在Perl中讀取持續更新的日誌文件?
- 18. 如何在Junit測試中讀取日誌文件
- 19. php讀取大文本文件日誌
- 20. 如何在Perl中讀取系統時間和日期?
- 21. 如何使用c讀取.sil(SmartInspect文件)日誌文件#
- 22. 什麼是系統日誌和系統日誌後臺進程
- 23. UNIX系統和Windows系統中讀取.CSV文件的差異
- 24. 什麼是日誌文件,我們如何在android中創建日誌文件?
- 25. 讀取構建/輸出/日誌Gradle/Android Studio中的文件
- 26. 系統日誌 - 日誌行分類
- 27. 更改系統日誌日誌路徑
- 28. 如何從系統文件夾讀取文件
- 29. 系統日誌在日誌輪轉後停止日誌記錄
- 30. 如何實現日誌系統
EboMike的鏈接後,導致404,在這裏它感動:http://code.google.com/p/android-log-collector/source/browse/trunk/在我的博客點擊此處瞭解詳情src/com/xtralogic/android/logcollector/SendLogActivity.java?r = 2 – Inoy 2012-10-11 09:25:30
(答案中的鏈接已更新,我也將關鍵部分複製到答案中) – EboMike 2013-11-12 00:24:07