开发者

How to make the Force Close window display friendly app name instead of a package name?

开发者 https://www.devze.com 2023-04-06 21:07 出处:网络
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 wher

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.

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.

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.

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);
    }
});


This currently isn't possible without modifying code at the system level. What you may have seen, however, is a custom error handler by an application. If you surround the bulk of your application code with a large try / catch block, you could pop up your own dialog informing the user of an error (with the application name and text of your choosing, of course). This would have to be done for each separate activity though, and its much better practice to simply avoid FCs altogether (hire a test group?).

0

精彩评论

暂无评论...
验证码 换一张
取 消