piks
piks

Reputation: 1673

Application running in background getting closed due to Excessive Wake lock error

I have developed one application which will have activities and one background service and all activities will have to bind with service when any request has to be sent to the server and response will be sent back to the register activities.Now there is one requirement where my application can run in foreground as well as in background also so for that i overridden device's back key and called moveTaskToBack() method and observed that my application is running perfectly when it goes to background, till this point application is working as expected but when device goes to sleep mode after some time application get closed , so we observed that as Wi-Fi is getting turned off so application's socket connection is also getting closed then we have acquired the partial wake lock of the application and application is working fine when it is running mode and device goes to lock/sleep mode but when application goes to background after 15 to 20 mins it is getting closed and when i see in DDMS it's displaying "Excessive wake lock in the application" then closing all windows and killed the application process. I am acquiring partial wake lock in background service's onCreate() method and releasing it in onDestroy() method.

does anyone help me out why it is happening and how to resolve it.

Regards, Piks

Upvotes: 0

Views: 1394

Answers (1)

Konstantin Pribluda
Konstantin Pribluda

Reputation: 12367

Well, apparently OS is smarter than you. It just tries to preent your application from sucking all the battery juice. To resolve this problem, you have to be polite citzizen. (and trust me, your application will be thrown off user phone on the spot when it behaves this way.)

Why it has to run all the time at all?

Upvotes: 1

Related Questions