Search code examples
android-locationfusedlocationproviderapiandroid-fusedlocation

Interval of updating location with Fused provider


I am facing with one problem. I am using Fused Location Provider and in docs it writes that when we use high priority, we will get updates on every 5 seconds, but I have watched some tutorial and that guy wrote this function

protected void createLocationRequest(){
    mLocationRequest=new LocationRequest();
    mLocationRequest.setInterval(INTERVAL);
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}

This INTERVAL is 10 seconds. Is that mean that I will get updates on every 10 seconds or on 5 seconds(like it writes in docs for using high priority)? Thanks in advance.


Solution

  • Interval 10 seconds : You will receive location updates approximately at each 10 seconds. But it's approximate, it may give location less or more than 10 seconds.

    fastest interval : This value must be lower than interval value. Okay we know that location updates will come us around 10 seconds(more or less). fastest means here, i dont wanna receive location updates lower than this value(fastest interval)

    Assume that you have below parameters

    • Interval : 10 seconds
    • Fastest Interval : 5 seconds

    And possible result could be like below (assumption)

    01:00:00 (Requested)

    01:00:12 (location update, 12 seconds)

    01:00:22 (location update, 10 seconds)

    01:00:30 (location update, 8 seconds)

    01:00:38 (location update, 8 seconds)

    01:00:46 (location update, 8 seconds)

    01:00:52 (location update, 6 seconds)

    01:00:59 (location update, 7 seconds)

    ...

    Result : You received location updates about 10 seconds and more than 5 seconds