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
Instead of using a
ServiceI would recommend that you take a look at theAlarmManagerclass. Depending on what you are trying to achieve this could be the better way to go. UsingAlarmManageryou 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 toRTC_WAKEUPwhich 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