Created
April 5, 2015 07:03
-
-
Save nisrulz/6084866f534a59ddc27c to your computer and use it in GitHub Desktop.
Android : Custom Uncaught Exception Handler
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 CustomUncaughtExpHandler implements Thread.UncaughtExceptionHandler { | |
/** | |
* Method to handle any exception thats not handled in code | |
* | |
* @param thread | |
* @param ex | |
*/ | |
@Override | |
public void uncaughtException(Thread thread, Throwable ex) { | |
Log.e(SP_Defaults.LOGTAG, | |
"*--------------- <APP> just ran into an Unhandled Exception ---------------*"); | |
Log.e(LOGTAG, "Unhandled Exception: " | |
+ ex.getClass().getName()); | |
Log.e(LOGTAG, "Cause : " + ex.getCause().toString()); | |
Log.e(LOGTAG, "Msg : " + ex.getMessage()); | |
android.os.Process.killProcess(android.os.Process.myPid()); | |
System.exit(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment