Skip to content

Instantly share code, notes, and snippets.

@Pitus660
Created November 14, 2014 16:11
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 Pitus660/87f3831beabe4a207ebe to your computer and use it in GitHub Desktop.
Save Pitus660/87f3831beabe4a207ebe to your computer and use it in GitHub Desktop.
CrashLytics method
private Thread.UncaughtExceptionHandler defaultHandler;
class PushUncaughtExceptionHandler
implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("PUSH expection----> " + thread.getName() + "exx--> " + ex.getCause()+"\n");
for (StackTraceElement element : ex.getStackTrace()) {
stringBuilder.append(element.toString() + "\n");
}
Log.e(stringBuilder.toString());
defaultHandler.uncaughtException(thread,ex);
}
}
PushtechAppBuilderImplementation(Context ctx) {
this.ctx = ctx.getApplicationContext();
packageName = ctx.getClass().getPackage().getName();
overrideLifeCycle(ctx);
crashExceptions();
}
private void crashExceptions() {
defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
PushUncaughtExceptionHandler pushHandler = new PushUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(pushHandler);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment