title: How to precisely calculate speed and distance using GPS? Tracking user location. App for running
body: <p>I want to make an application for running which tracks user location, speed and beaten distance. Currently I am using Google Location Services API to get GPS data, because Google recommends it on <a href="https://developer.android.com/reference/android/location/package-summary" rel="nofollow noreferrer">the official site</a>. </p>
  
  <p>But the problem is that I can recive location updates only every 10 seconds, which is OK if it comes only to drawning location on the map, but I want to calculte user current speed(km/h), current pace (min/m) and calculate exact time when he makes one lap (1km or 1 mile). And here is the problem if I am getting updates every 10sec I am not able to calculate precisely those parameters. For example, the update comes when user is on 996m and in 4m he will make one lap. But the next update will not be available for 10 sec, so it will come on e.g. 1010m. And that is not what user would like to have...</p>
  
  <p>How to solve this problem? What do you think?</p>
  
  <p><a href="https://developer.android.com/training/location/receive-location-updates#java" rel="nofollow noreferrer">I am using the exact code form here.</a> </p>
  
  <p>Where location request looks like:</p>
  
  <pre><code>LocationRequest mLocationRequest = new LocationRequest();
  mLocationRequest.setInterval(10000);
  mLocationRequest.setFastestInterval(5000);
  mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  </code></pre>
  
  <p>From <a href="https://developer.android.com/training/location/change-location-settings" rel="nofollow noreferrer">docs</a>:</p>
  
  <blockquote>
    <p>The priority of PRIORITY_HIGH_ACCURACY, combined with the ACCESS_FINE_LOCATION permission setting that you've defined in the app manifest, and a fast update interval of 5000 milliseconds (5 seconds), causes the fused location provider to return location updates that are accurate to within a few feet. This approach is appropriate for mapping apps that display the location in real time.</p>
  </blockquote>
  
  <p>But it isn't enough. Even though I change interval for smaller it always is 10sec.</p>