当前位置:网站首页>Anr error encountered

Anr error encountered

2022-07-23 11:06:00 Road of Kings 001

Recently, I was solving a problem Android problem . The problems are as follows : When uploading on the mobile phone , Too many tasks , Report error , Even prompt “ No response , Whether to shut down ”.

obviously , This is the encounter with ANR error , That is to say Androdi The phone has no response error .

The reason for this error is :Android In order to respond quickly , Put related tasks related to graphic operation , Are put into the main thread ; But if the main thread is too busy to respond , Related errors will occur (When the UI thread of an Android app is blocked for too long, an "Application Not Responding" (ANR) error is triggered.).

resolvent : Put too much work into sub threads ; There are too many upload tasks in this network operation , It should be put into the sub thread .

The code is as follows :

new Thread(){
    @Override
    public void run(){
        // The relevant operation 
    }
}.start();

After testing , Sure enough , Problem solving . 

原网站

版权声明
本文为[Road of Kings 001]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230536560774.html