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. Android系统日志文件
- 2. 如何从系统日志/系统日志获取数据
- 3. 如何在Redhat中获取系统日志文件
- 4. 如何获取系统日志形式4.3 android操作系统
- 5. Android文件系统日志记录
- 6. 阅读Android 4.1上的系统日志
- 7. Python系统日志文件
- 8. 使用PHP读取系统日志
- 9. 如何读取系统日志中的安卓果冻豆
- 10. 系统日志:在日志文件中错误PROGRAMNAME(#001)
- 11. 如何使用系统日志获取perl stderr到httpd日志文件
- 12. android系统和日志
- 13. FastMM4,如何读取日志文件?
- 14. 在java中读取日志文件
- 15. Android:只读文件系统
- 16. 无法读取android系统日食的项目文件
- 17. 如何读取日志从日志文件,因为它发生
- 18. 如何在C++中读取这个日志文本文件
- 19. R如何导入日志文件系统json文件?
- 20. 无法读取远程系统事件日志
- 21. 如何从Java程序获取Android系统日志
- 22. 在日志解析器中读取IIS日志文件
- 23. 如何发送系统日志通过TCP在系统日志服务器
- 24. 追踪日志文件系统
- 25. Ubuntu:大系统日志和kern.log文件
- 26. 读取Android文件系统中的所有文件
- 27. 获取系统日志在果冻豆
- 28. 如何在Junit测试中读取日志文件
- 29. 如何在Perl中读取持续更新的日志文件?
- 30. 如何在Cloud9中读取Heroku日志?
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