Question: I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval 

When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins.

I would like to know the difference. I couldn't understand what exactly is written in the developer page for this <https://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html>

Also: Is there an inbuilt function to check the location updates only if the distances of the first update are more than 20meters with the second update? 

Thanks!

Answer: 
Based on the relevant [Android documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest):

* `setInterval(long)` means - set the interval in which you want to get locations.
* `setFastestInterval(long)` means - if a location is available sooner you can get it (i.e. another app is using the location services).

For example, you start your application and register it via `setInterval(60*1000)`, that means that you'll get updates every 60 seconds.

Now you call `setFastestInterval(10*1000)`. If you are the only app which use the location services you will continue to receive updates approximately every 60 seconds. If another app is using the location services with a higher rate of updates, you will get more location updates (but no more frequently that every 10 seconds).

I believe that it has a good impact on battery life consumed by your app, you define the maximum amount of time that you can wait while saying that if an update is available, you want it. The battery consumption will be credited to the app which requested the more frequent updates and not yours.
> 
> Also: Is there an inbuilt function to check the location updates only if the distances of the first update are more than 20meters with the second update?
> 
> 
> 

LocationRequest has a method you can use to set the minimum distance between updates.

```
int minimumDistanceBetweenUpdates = 20;

LocationRequest request = new LocationRequest();
request.setMinimumDisplacement(minimumDistanceBetweenUpdates);
// ... request.setInterval(interval); etc

```