Created
April 7, 2016 13:22
-
-
Save mmanishh/330fec841fe90e1ee6792fadd48ee5f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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