Hardik Parmar
Hardik Parmar

Reputation: 712

it's possible to change message when Android application is unfortunately apps has stopped?

I have not any idea about for this. This message is changes or not in android application. I want to make that custom.

Thanks in advance.

Upvotes: 0

Views: 501

Answers (1)

Krishna Chandran
Krishna Chandran

Reputation: 399

You have to implement 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);
    }
}

Upvotes: 2

Related Questions