I want to report a log when the application crash.And i want to send this report to my mail how can i implement this can any one give an idea?
Thanks in advance
I want to report a log when the application crash.And i want to send this report to my mail how can i implement this can any one give an idea?
Thanks in advance
What you need is a crash report service. There are too many options: Bugsense, Flurry, TestFlight, Acralizer, Google Analytics for Android, Crittercism, etc.
Of course this is good idea to catch all the exception and send it using native email, but this is a sample application using which you can Collects output of logcat and sends it to a email or messaging.
https://code.google.com/p/android-log-collector/
You can get some references here also
Just try this...
Process process = Runtime.getRuntime().exec("logcat -e");
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
StringBuilder log=new StringBuilder();
String line = "";
while ((line = bufferedReader.readLine()) != null) {
log.append(line);
}
now mail string line using intents...
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"aaa@sdf.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "Crash Report");
email.putExtra(Intent.EXTRA_TEXT, line);
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
use this link more help....
http://www.coderzheaven.com/2011/07/16/how-to-read-logcat-contents-programmatically-in-android/
When using Crittercism, they provide the capability to get a snapshot of the logcat with a crash report.
See how to activate that here:
https://app.crittercism.com/developers/docs-android#Include_Logcat
This is currently available under a paid plan, see here for reference:
If you are using ACRA to capture crashes in your app then it is just a matter of configuring ACRA to send the report via email.
See https://github.com/ACRA/acra/wiki/AdvancedUsage#sending-reports-by-email
But if you have a large number of users (or potentially will) then I would strongly recommend you use one of the hosted crash reporting services to aggregate your crashes. Because even if your app is perfect it will generate crashes from errors in libraries you use, AOSP itself, weird devices, weird Android implementations, weird device states.