A J
A J

Reputation: 4632

GPS location update perameter

glocManager  = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        glocListener = new MyLocationListenerGPS();
        glocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                1000 * 1,  // 1 Sec        
                1,         // 1 meter           
                glocListener);

This code is for getting location using GPS But it will update location when BOTH CONDITION GET SATISFIED (1Sec and 1 meter) or ONLY ONE?

Upvotes: 0

Views: 98

Answers (2)

Benjamin Schwalb
Benjamin Schwalb

Reputation: 1134

As the Tooltip/Javadoc says:

 Parameters
       provider  the name of the provider with which to register 
       minTime  minimum time interval between location updates, in milliseconds 
       minDistance  minimum distance between location updates, in meters 

Let´s take your values: 1s, 1m:
The Location is updated every second, IF the distance between last second and now is greater than one meter.
The Location is updated every meter, IF the last update was atleast one second ago.

TL;DR: It´s AND, the Location is only updated, if both are true.

Upvotes: 1

Ion Aalbers
Ion Aalbers

Reputation: 8030

Reading the javadoc it says:

The minDistance parameter can also be used to control the frequency of location updates. 
If it is greater than 0 then the location provider will only send your application an update when the location has changed by at least minDistance meters, 
AND at least minTime milliseconds have passed

Link

Upvotes: 1

Related Questions