調用此方法onDestory您的主要活動。
public void SendLoagcatMail(){
// save logcat in file
File outputFile = new File(Environment.getExternalStorageDirectory(),
"logcat.txt");
try {
Runtime.getRuntime().exec(
"logcat -f " + outputFile.getAbsolutePath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//send file using email
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// Set type to "email"
emailIntent.setType("vnd.android.cursor.dir/email");
String to[] = {"[email protected]"};
emailIntent .putExtra(Intent.EXTRA_EMAIL, to);
// the attachment
emailIntent .putExtra(Intent.EXTRA_STREAM, outputFile.getAbsolutePath());
// the mail subject
emailIntent .putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(emailIntent , "Send email..."));
}
你讀過這https://github.com/ACRA/acra? – deniz 2014-09-10 12:37:32
[發送一個App的logcat的輸出到的emailadress](http://stackoverflow.com/questions/2852181/send-logcat-output-of-an-app-to-an-emailadress) – avalancha 2015-11-04 08:42:29