0

How to find user updated location after every 30 minutes but there is no requirement to draw the map... The requirement is just to find the location and send it to any server after every 30 minutes.???

Thanks in advance...

Coral Doe
  • 1,925
  • 3
  • 19
  • 36
Maddy Sharma
  • 4,870
  • 2
  • 34
  • 40

2 Answers2

2

The most reliable method according to me is have an AlarmManager wake up a Service every n minutes and send location updates to server.

Don't rely on the minimum time set on the LocationListener.

This is from personal experience (I have an app where I was using this method and it was totally unreliable).

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
0

Do it in a background service, and when you implement the LocationListener interface, you can send the location off to your server in the onLocationChanged(Location location) method e.g.

@Override
public void onLocationChanged(Location location)
{           
    // Send location to server...

    locationManager.removeUpdates(this);            
    detachLocationListeners();
}
John J Smith
  • 11,435
  • 9
  • 53
  • 72
  • The time and distance to receive update of lat/lon is 1 minute and 10 meter respectively. I cant do it in background because I also provide a pause button to pause the receiving of lat/lon. If i use this then I receive lat/lon in case either I close my app. I think u understand.there are 2 buttons named pause(to pause to record route), start/stop(to start and stop recording). – Maddy Sharma Sep 16 '12 at 18:43
  • You could launch the service every 30 minutes using the AlarmManager and tie this into the buttons - either start the AlarmManager with intents or stop them. – John J Smith Sep 16 '12 at 19:43
  • I can provide the time and distance to receive updates with the help of the parameters provided to the overridden method lManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2, 200, locationListener); like. It has four parameters. But when i call lManager.removeUpdates(locationListener); on my stop.setOnClickListener(l), I receive lat/lon either I close the App. Why this not works on stop button clicking. – Maddy Sharma Sep 17 '12 at 19:51