Reputation: 400
I wrote an android service, which search for GPS every 5 minutes. I have used a timer inside the service. But this timer is not running when the phone is in the sleep mode.
Can't I run a service when the phone is in sleep mode? How can I over come this problem? pls help me.
Thanks in Advance
Upvotes: 1
Views: 1784
Reputation: 5223
Instead of using a Service
I would recommend that you take a look at the AlarmManager
class. Depending on what you are trying to achieve this could be the better way to go. Using AlarmManager
you can schedule a task (piece of code) to be executed at a given point in time. When you set an alarm you can set it's mode to RTC_WAKEUP
which will wake the device up if it's sleeping and run the code associated with the alarm.
Take a look here for more details: http://developer.android.com/reference/android/app/AlarmManager.html
Upvotes: 2