Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace standard error message?

When application crashes we can see something like Your wonderful app was stopped. How can I change this text?

like image 628
Yarh Avatar asked Sep 23 '26 23:09

Yarh


1 Answers

Implements UncaughtExceptionHandler and assign it to your Application

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
    }
}

public final class CrashHandler implements UncaughtExceptionHandler {
    private final UncaughtExceptionHandler handler;

    public CrashHandler() {
        // Uncomment this line if you want to show the default app crash message
        //this.handler = Thread.getDefaultUncaughtExceptionHandler();
    }

    @Override
    public void uncaughtException(final Thread thread, final Throwable throwable) {
        // Show pretty message to user

        // Uncomment this line to show the default app crash message
        //this.handler.uncaughtException(thread, throwable);
    }
}
like image 143
Alan Avatar answered Sep 26 '26 20:09

Alan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!