Is there any way to specify the time intervals that the Location Manager broadcasts the current location?
I am using a method called startListening:
public void startListening() {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
0,
0,
this
);
}
Thanks
public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener, Looper looper)Registers the current activity to be notified periodically by the named provider. Periodically, the supplied LocationListener will be called with the current Location or with status updates.
It may take a while to receive the most recent location. If an immediate location is required, applications may use the getLastKnownLocation(String) method.
In case the provider is disabled by the user, updates will stop, and the
onProviderDisabled(String)method will be called. As soon as the provider is enabled again, the onProviderEnabled(String) method will be called and location updates will start again.The frequency of notification may be controlled using the
minTimeandminDistanceparameters. IfminTimeis greater than 0, the LocationManager could potentially rest forminTimemilliseconds between location updates to conserve power. IfminDistanceis greater than 0, a location will only be broadcasted if the device moves byminDistancemeters. To obtain notifications as frequently as possible, set both parameters to 0.Background services should be careful about setting a sufficiently high
minTimeso that the device doesn’t consume too much power by keeping the GPS or wireless radios on all the time. In particular, values under 60000ms are not recommended.The supplied Looper is used to implement the callback mechanism.
Parameters
with which to register
minimum time interval for
notifications, in milliseconds. This
field is only used as a hint to
conserve power, and actual time
between location updates may be
greater or lesser than this value.
interval for notifications, in meters
method will be called for each
location update
object whose message queue will be
used to implement the callback
mechanism.
Throws
IllegalArgumentExceptionif provider is null or doesn’t existIllegalArgumentExceptionif listener is nullIllegalArgumentExceptionif looper is nullSecurityExceptionif no suitable permission is present for the provider.