gpt4 book ai didi

android - 如何替换标准错误信息?

转载 作者:太空宇宙 更新时间:2023-11-03 12:36:49 25 4
gpt4 key购买 nike

当应用程序崩溃时,我们可以看到类似您的精彩应用已停止的信息。如何更改此文本?

最佳答案

实现 UncaughtExceptionHandler 并将其分配给您的 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);
}
}

关于android - 如何替换标准错误信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17210731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com