Skip to content

Instantly share code, notes, and snippets.

@mmanishh
Created April 7, 2016 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmanishh/330fec841fe90e1ee6792fadd48ee5f2 to your computer and use it in GitHub Desktop.
Save mmanishh/330fec841fe90e1ee6792fadd48ee5f2 to your computer and use it in GitHub Desktop.
public class LoggingExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
StringWriter stackTrace = new StringWriter();
ex.printStackTrace(new PrintWriter(stackTrace));
String msg = "WALT crashed with the following exception:\n" + stackTrace;
// Fire a new activity showing the stack trace
Intent intent = new Intent(MainActivity.this, CrashLogActivity.class);
intent.putExtra("crash_log", msg);
MainActivity.this.startActivity(intent);
// Terminate this process
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment