There is a way to install a global exception handler that will catch any exception thrown by this thread. Thus, you establish it in your main activity, and it will be applied to each sub-activity.
But! Never do this to suppress exceptions and just show the dialog because it looks better (I would even argue that this will be the dumbest idea of โโeverything you can have since you "disable the basic function that will help you fix exceptional behavior "). This is not what the handler is for! Typically, a handler calls the previous default handler to preserve the default exception handling. He only wants crash information.
I wrote this because of this answer . No offense! This is just a big fat warning to try and get the wrong behavior.
final UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable ex) {
Knickedi
source share