Hi, I'm in the middle of a battery saver app. Its similar to Juice Defender, the main idea is to basically turn on/off wifi/data-mobile periodically.
I've been developing all the time using my phone connected to the IDE, and using lots of logs.
I am using a service, which is running in foreground (startforeground), and using timers to turn on and off the conectivity. I also have a "night time" (during some hours, the phone wont turn on conectivity) and a "peek time" (during some hours the frequency for conectivity will be more often) which are using timers too.
Everything was ok, until I decided to test it without the cable. When the phone screen goes off, its seems that the phone enters in deep sleep, and the service is not working during that time, until I unlock the phone.
During the time that the phone is "sleeping", all the timers are like frozen, and when I turn on the screen, the timers continue working but with a "cut interval".
Like for example, if I set Timer1 to tick in 5 minutes, wait 1 minute with screen on, then turn off screen for 2 minutes, and the turn on screen, the timer will fire in 4 minutes anyway (and it should be 2 minutes).
- It seems that one solution is using Partial lock, but I dont want to have it enabled all the time, because it wont save me battery.
- Another solutions could be using StartServiceAt, but i have lots of timers (like turn on/off, check conectivity, start/finish night time, start/finish peek time, and some others)
Any ideas!?
I've been developing all the time using my phone connected to the IDE, and using lots of logs.
I am using a service, which is running in foreground (startforeground), and using timers to turn on and off the conectivity. I also have a "night time" (during some hours, the phone wont turn on conectivity) and a "peek time" (during some hours the frequency for conectivity will be more often) which are using timers too.
Everything was ok, until I decided to test it without the cable. When the phone screen goes off, its seems that the phone enters in deep sleep, and the service is not working during that time, until I unlock the phone.
During the time that the phone is "sleeping", all the timers are like frozen, and when I turn on the screen, the timers continue working but with a "cut interval".
Like for example, if I set Timer1 to tick in 5 minutes, wait 1 minute with screen on, then turn off screen for 2 minutes, and the turn on screen, the timer will fire in 4 minutes anyway (and it should be 2 minutes).
- It seems that one solution is using Partial lock, but I dont want to have it enabled all the time, because it wont save me battery.
- Another solutions could be using StartServiceAt, but i have lots of timers (like turn on/off, check conectivity, start/finish night time, start/finish peek time, and some others)
Any ideas!?