Created
November 14, 2014 16:11
-
-
Save Pitus660/87f3831beabe4a207ebe to your computer and use it in GitHub Desktop.
CrashLytics method
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
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