1 package net.ktnx.mobileledger.ui.activity;
3 import android.os.Bundle;
4 import android.support.annotation.Nullable;
5 import android.support.v7.app.AppCompatActivity;
6 import android.util.Log;
8 import net.ktnx.mobileledger.ui.CrashReportDialogFragment;
10 import java.io.PrintWriter;
11 import java.io.StringWriter;
13 public class CrashReportingActivity extends AppCompatActivity {
15 protected void onCreate(@Nullable Bundle savedInstanceState) {
16 super.onCreate(savedInstanceState);
18 Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
20 public void uncaughtException(Thread t, Throwable e) {
21 StringWriter sw = new StringWriter();
22 PrintWriter pw = new PrintWriter(sw);
23 e.printStackTrace(pw);
25 Log.e(null, sw.toString());
27 CrashReportDialogFragment df = new CrashReportDialogFragment();
28 df.setCrashReportText(sw.toString());
29 df.show(getSupportFragmentManager(), "crash_report");
32 Log.d("crash", "Uncaught exception handler set");