I've been trying to work out this issue the whole day without luck. Here's what happens: I tested my app and it worked perfectly, then I unplug the phone and leave the app in the background, and after a few minutes, it doesn't start anymore and must be force closed. Strangely enough, the problem doesn't happen when the device is plugged in: I left it there for 2 hours straight and it worked, then I unplugged it and 5 minutes later the app was frozen. I suspect it has something to do with the phone entering deep sleep (I'll try with a wakelock just to be sure). When I plug in the phone and look at logcat, all I see are warnings that the app must be force closed, and this suspicious looking line:
Activity reported stop but no longer stopping
What does it mean? I didn't stop the activity, it's running in the background, and it wasn't killed by the system either because when that happens the app doesn't freeze, it gets killed and must be restarted.
I've never had this problem before and I can't find anything on the internet about this issue: have you ever encountered something like this? What should I do?
While charging and usb debugging many power management restrictions don't apply. Here check it. In each android version, there are more restrictions coming on background processes for power management.
My prediction is when you unplug your app encounters with some of those restrictions and due to lack of any wakelock acquired, your app is not able to use any cpu. For example, if you have a service using a handler with post delayed, it never does the job until some cpu time gets elapsed. Check its documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With