如何在强制关闭或ANR消息出现之前显示自定义消息 [英] How to display Custom message before force close or ANR message will occur

查看:142
本文介绍了如何在强制关闭或ANR消息出现之前显示自定义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在取消赎回或应用程序不响应消息出现之前显示自定义错误消息.

How i can display custom error message before foreclose or Application not responding message will happen for an application.

我可以显示请稍候....."之类的自定义消息,而不是应用程序未响应消息.

Can i display Custom message like "Please wait....." instead of Application not responding message.

谢谢

推荐答案

您必须确保正在处理所有引发的异常.这就是导致强制关闭(未捕获的异常)的原因.至于不响应"消息,同样,这取决于开发人员.您需要产生新线程并执行异步任务,这样处理不会阻塞主线程,而主线程正是UI运行的对象.当主线程被阻塞时,即发生无响应"消息.如果生成新线程,则可以向用户显示您想要的哪种消息,以通知用户正在处理某些事情.

You have to make sure you are handling any exceptions that are thrown. That is what causes a force close, an uncaught exception. as for the "not responding" message, again, this is up to the developer. You need to spawn new threads and do async tasks, that way processing does not block the main thread, which is what the UI runs on. When the main thread is blocked, that is when the "not responding" message happens. If you spawn a new thread, then you can display what ever kind of message you want to the user to notify them that something is processing.

这篇关于如何在强制关闭或ANR消息出现之前显示自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆