简体   繁体   中英

ANR on background services

I'm running 2 background services

One to detect the shaking and the other to detect the long press for power button.

The services are working perfectly in the background but sometimes when the application is in the background, I get this message popping again and again "Application_name isn't responding, Wait or stop". Both the services are normal services with START_STICKY on onStartCommand()

I've declared both the services in manifest.

And one more thing, Sometimes when I open my application (After the services are running for a while), I get a plain white screen on the app startup and it just sticks there.

If anyone have any idea about these scenarios please let me know. and if you need to see the code too, let me know.

  1. Look for UI updates that are happening in the background.
  2. Make sure there are no unnecessary Timer() in your code. If there, then stop them when they are not required.
  3. If you are using Geocoder try to fetch location from a back ground thread.
  4. Last option is to try implementing Leak Canary and patch all the leaks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM