title: Best way to get user GPS location in background in Android
body: <p>In my android app i want to get user current location every few minute interval and update in to my center server using web service.
  Currently i am using Fused Location Provide for get user current location, See <a href="https://developer.android.com/reference/com/google/android/gms/location/FusedLocationProviderApi.html">link</a></p>
  
  <p>now i want to know what is the best way to get user location frequently and call web service.</p>
  
  <p>below is my code which gives me user current location: - </p>
  
  <pre><code>     locationrequest = LocationRequest.create();
       locationrequest.setInterval(10000);
       locationclient.requestLocationUpdates(locationrequest,new com.google.android.gms.location.LocationListener() {
  
          @Override
          public void onLocationChanged(Location location) {
                Log.i(TAG, "Last Known Location :" + location.getLatitude() + "," + location.getLongitude());
          }
      });
  </code></pre>
  
  <p>now from where i have to call this code.
  Can i use this in a background service or some where else.</p>
  
  <p>Please provide your idea.</p>
  
  <p>TIA.</p>