Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android : Custom Uncaught Exception Handler
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