I have service that is implementing location listener. Now my question is how to make sure that my service will capture location even in sleep mode. I have read about alarm manager
alarm.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtMillis, intervalMillis, operation);
but how to use it. here is my code.. any help would be appreciated..
my service
public class LocationCaptureService extends Service implements LocationListener {
public static int inteval;
java.sql.Timestamp createdTime;
LocationManager LocationMngr;
@Override
public void onCreate() {
inteval=10*1000;
startLocationListener(inteval);
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
private void startLocationListener(int inteval,String nwProvider) {
this.LocationMngr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
this.LocationMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, inteval, 0, this);
}
public void onLocationChanged(Location location) {
String status="c",S=null;
double longitude,lattitude,altitude;
g_currentBestLocation = location;
createdTime = new Timestamp (new java.util.Date().getTime());
longitude=location.getLongitude();
lattitude=location.getLatitude();
altitude=location.getAltitude();
//use this
}
}
public void onProviderDisabled(String provider) {}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
}