如何使强制关闭窗口显示友好的应用程序名称,而不是包的名字吗?关闭窗口、应用程序、而不是、友好

2023-09-07 09:24:57 作者:枯守一座城

我认为这是可以用一个更可读的应用程序名称替换强制关闭在Android的窗口中的Java包名。我找不到任何信息如何做到这一点还是记得在那里我看到它,但是。我试图在谷歌搜索和SO没有运气。我在我的清单的活性和应用程序标记标签。

I think it is possible to replace the Java package name in Force Close window in Android with a more readable application name. I cannot find any information how to do it or recall where I saw it, however. I tried to search on Google and SO without luck. I have labels for both activity and application tags in my Manifest.

是否有可能安装在FC窗口自定义应用程序的名称,如果是这样,怎么办呢?

Is it possible to setup a custom application name in FC window, and if it is, how to do it?

推荐答案

有一种方法来设置一个全球性的异常处理程序,这将赶上这也是造成该线程任何异常。所以,你在你的主要活动设置它,它适用于所有的子活动。

There is a way to set a global exception handler, which will catch any exception which is caused on that thread. So you set it in your main activity and it will apply to every subactivity.

但是!永远不要去做那些燮preSS例外,只是显示一个对话框,因为它看起来更好(我甚至会肯定,这将是你的最愚蠢的想法可以有,因为你是禁用的基本特征是有帮助你解决异常行为)。这不是处理程序是什么样的存在!通常情况下,处理程序调用previous默认处理程序,以preserve默认的异常处理。它只是想崩溃的信息。

But! Don't ever do that to suppress exceptions and simply show a dialog because it looks nicer (I would even affirm that this would be the most dumb idea of all you can have since you're disabling a basic feature which is there to help you to fix exceptional behavior). It's not what the handler is there for! Usually the handler invokes the previous default handler to preserve the default exception handling. It only wants the crash info.

我写的this回答。没有恶意!这只是一个大胖子警告,试图强行错误的行为。

I wrote that because of this answer. No offence! It's only a big fat warning to attempt to force wrong behavior.

final UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        // get the crash info
        defaultHandler.uncaughtException(thread, ex);
    }
});