潇湘沐
两个步骤:生成日志加载Gmail以发送日志。生成日志File generateLog() {
File logFolder = new File(Environment.getExternalStorageDirectory(), "MyFolder");
if (!logFolder.exists()) {
logFolder.mkdir();
}
String filename = "myapp_log_" + new Date().getTime() + ".log";
File logFile = new File(logFolder, filename);
try {
String[] cmd = new String[] { "logcat", "-f", logFile.getAbsolutePath(), "-v", "time", "ActivityManager:W", "myapp:D" };
Runtime.getRuntime().exec(cmd);
Toaster.shortDebug("Log generated to: " + filename);
return logFile;
}
catch (IOException ioEx) {
ioEx.printStackTrace();
}
return null;}加载Gmail以发送日志File logFile = generateLog();Intent intent = new Intent(Intent.ACTION_SEND);intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(logFile));intent.setType("multipart/");startActivity(intent);~~对于#2 - 有很多不同的答案,有关如何加载日志文件以查看和发送。最后,这里的解决方案实际上适用于:加载Gmail作为选项成功附加文件