Breaking News

How to send app crash reports in Android

How to send app crash reports in Android



import android.content.Context;
import android.content.Intent;
import android.util.Log;

 * Created by amit on 22/4/16.
public class BaseApplication extends Application {

    public void onCreate() {
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

            public void uncaughtException(Thread thread, Throwable ex) {
                handleUncaughtException(thread, ex);


    public void handleUncaughtException (Thread thread, Throwable e)
        String stackTrace = Log.getStackTraceString(e);
        String message = e.getMessage();

        Intent intent = new Intent (Intent.ACTION_SEND);
        intent.putExtra (Intent.EXTRA_EMAIL, new String[] {""});
        intent.putExtra (Intent.EXTRA_SUBJECT, "MyApp Crash log file");
        intent.putExtra (Intent.EXTRA_TEXT, stackTrace);
 // required when starting from Application



In your AndroidManifest.xml specify the name for your application tag to be the name of your Class file.

Whenever your application crashes, it will get caught in your custom Application class, and then it will call the default  mailing application in the device by setting up a Mail Intent. Everything in the mail will already be filled – the user just has to click on Send. Or he can even copy the mail content and save it somewhere.

No comments