0

I have created an app which will start a service. In my service, I created a timer that will do something periodically. I didn't use any wakelock.

After I press the power button and wait for sometime, it seems that my service still keeps printing something periodically into the eclipse( I keep the usb connected in order to see the message in eclipse).

So my service is still running and will never go sleep even the power button is pushed?Then it will keep draining the battery? Is that caused by the usb connection? Does anyone have such experience?

jgauffin
  • 99,844
  • 45
  • 235
  • 372
Hao Shen
  • 2,605
  • 3
  • 37
  • 68

1 Answers1

1

Keeping the phone plugged in prevents it from going to sleep. A better test would be to disconnect it from adb, wait until a couple of the timer intervals have passed, and then plug the phone back in and check logcat. I don't recall offhand if eclipse shows the time associated with each logcat message. If not, you can use adb logcat -vtime to get this information.

JesusFreke
  • 19,784
  • 5
  • 65
  • 68