Skip to content

Instantly share code, notes, and snippets.

@nisrulz
Created April 5, 2015 07:03
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 nisrulz/6084866f534a59ddc27c to your computer and use it in GitHub Desktop.
Save nisrulz/6084866f534a59ddc27c to your computer and use it in GitHub Desktop.
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