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