倾听并回应ANR?ANR

2023-09-06 14:39:05 作者:有本事你爱我一辈子

有没有办法得到通知,当你的应用程序触发ANR(应用程序无响应)?类似于默认的异常处理?

Is there a way to get notified when your app triggers an ANR (Application Not Responding)? Similar to the default exception handler?

在期待的你会用它做什么的答案,只是记录。不是做任何事情。

In anticipation of the "what would you do with it" answers, just logging. Not "doing" anything.

推荐答案

没有。与你发生过程中的VM内,您可以捕获异常,ANR是由一个系统监视程序,你的虚拟机外部产生。谷歌提供的触发器和避免信息

No. Unlike exceptions that occur within your process's VM that you can catch, the ANR is generated by a system watchdog, outside your VM. Google offers info on triggers and avoidance