0

How quickly does Android go to sleep after wakelock is released?

I am working on an app which uses the accelerometer in the background, and because of its high power consumption I am investigating how best to allow the device to go to sleep, at least for every other minute or so.

I cannot let the device go to sleep for as long as an hour, or even 10 minutes -- that would be only possible in the case where I would develop some kind of intelligent scheduler based its predictions of user behavior. I do not have enough time for this.

Thus I am asking if when I let my app go to sleep, and actually unregister the sensor update listener, would the device even go to sleep in such a small time interval? (I would think that there would be some timeout to prevent runnning all that stuff that is necessary when device goes out of standby mode.)

I am using the slowest accelerometer mode: SENSOR_DELAY_NORMAL. Right now, my service holds the device on wakelock all the time. This only lasts for about 12 hours of standby -- getting twice as much would be sufficient.

Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
simekadam
  • 7,334
  • 11
  • 56
  • 79

1 Answers1

0

Does anybody know how quickly goes android to sleep after wakelock is released?

It could be in under a millisecond.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ok..Maybe wrong question..I just need to know if it worth to periodicaly toggle the accelerometer cca every other minute. For example when turning off GPS it holds the satelites lock for another 30s before it goes to sleep..So toggling GPS every 30seconds does not have impact on battery life (it could make it actually even worse) Same thing with 3g radios. It holds full power event couple of seconds after the actuall transfer is ended. – simekadam Apr 20 '12 at 13:27
  • @Sima: "I just need to know if it worth to periodicaly toggle the accelerometer cca every other minute" -- try it and see if it works for you. I do not recommend that people use sensors in the background this way, so I have no clue what the power characteristics are in that circumstance. – CommonsWare Apr 20 '12 at 13:34
  • Ok.. Solved. My background service is now scheduled to start every five minutes for as long as is necessary to determine if the devi device is moving. And it actually does not cause any significant battery drain at all. While having some self learning scheduler to alter intervals to be more appropriate to user behavior, the solution would pbe erfect.. – simekadam Apr 21 '12 at 07:56