views:

41

answers:

1

hi

my application objective is to save location updates every ,let say, 20 minuets .

I used service and it worked fine , but when i lock the screen or it is locked automatically the service stop running . when i unlock it , service runs again.

highlight on my code:

Service()

onCreat(){
   call timer();
 }

timer(){
   code
 }

How to make my code run all the time in all conditions?

A: 

The right way to arrange for your service to do work on a scheduled basis (e.g., "call timer()"), including waking up the device, is to use the AlarmManager, probably along with my WakefulIntentService or something similar.

CommonsWare