Shashank Degloorkar
Shashank Degloorkar

Reputation: 3221

MapView refresh event fires on regular interval i dont want that to happpen

locationManager.requestLocationUpdates(
  LocationManager.GPS_PROVIDER,30000,100, new GeoUpdateHandler() 
);

The map refreshes after a regular interval of 30 secs.

Suppose I'm at the same position for more than 2 minutes then the map will be refreshed more than 4 times; I don't want it to happen.

Can anyone suggest me that i provide time as null?

Upvotes: 1

Views: 276

Answers (2)

citizen conn
citizen conn

Reputation: 15390

The minimum time and minimum distance values are there to prevent that.

In the case of your sample code, that event should not get fired unless the user has moved more than 100 meters from the previous update. Thats what the minDistance property is about.

http://developer.android.com/reference/android/location/LocationManager.html

Upvotes: 1

devunwired
devunwired

Reputation: 63293

The SDK documentation on LocationManager.requestLocationUpdates() has your answer on how to utilize the minTime and minDistance parameters to adjust the update frequency for your location:

LocationManager SDK Documentation

The frequency of notification may be controlled using the minTime and minDistance parameters. If minTime is greater than 0, the LocationManager could potentially rest for minTime milliseconds between location updates to conserve power. If minDistance is greater than 0, a location will only be broadcasted if the device moves by minDistance meters. To obtain notifications as frequently as possible, set both parameters to 0.

Basically, you are getting 30 second updates because you have set minTime to 30000. You may consider setting this value to 0 and increasing the value of minDistance larger than 100 to get location updates that are more akin to when the user physically moves a significant distance.

Hope that Helps.

Upvotes: 2

Related Questions