使用开源项目ANR-WatchDog来检測ANR。下载链接为:https://github.com/SalomonBrys/ANR-WatchDog
Eclipse版本号仅仅需下载相应的jar包。在主线程调用new ANRWatchDog().start();


该ANR-WatchDog实现原理:

ANR-WatchDog创建一个监測线程,该线程不断往UI线程post一个任务,然后睡眠固定时间,等该线程又一次起来后检測之前post的任务是否运行了,假设任务未被运行,则生成ANRError,并终止进程。

相关文章:

  • 2022-12-23
  • 2022-01-02
  • 2021-10-24
  • 2021-10-08
  • 2021-08-20
  • 2021-10-11
猜你喜欢
  • 2021-10-29
  • 2021-07-19
  • 2021-06-10
  • 2021-08-27
相关资源
相似解决方案