Soyeon Kim
Soyeon Kim

Reputation: 608

How does requestLocationUpdates() get location even though has paramter 0?

I want to get location of device so used this line:

mLocationManager.requestLocationUpdates(provider, 0, 0, mLocationListener);

I know what each parameter do work, but can't understand how does it get location even though parameter has 0 value.

Upvotes: 0

Views: 45

Answers (2)

Jayamurugan
Jayamurugan

Reputation: 532

mLocationManager.requestLocationUpdates(provider, 0, 0, mLocationListener);

In this the first 0 represents "Minimum Time" between the updates whereas the second 0 "Minimum Distance" between the updates.Hence, if you set them both to zero then the location change would be updated more frequently without any limits.

Upvotes: 1

Jitesh Mohite
Jitesh Mohite

Reputation: 34250

According to documentation

requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener)

Register for location updates using the named provider, and a pending intent.

Even if you using minTime = 0 and minDistance = 0 they will provide you location. So, location fetches every time without any specific interval and time. It is up to us what values we have used there.

In your case they will provide you location every time without waiting for specific interval or time.

Upvotes: 1

Related Questions