title: i want to post location updates every 15mins to server even when the app is not running in the foreground
body: <p>I want the location updates to be sent to the server every 15mins to time interval from android phone to the server.Is the service or the alarm manager is the best option.</p>
  
  <p>If i start a service,can i start an asynctask to post locations to the server.?</p>
  
  <p>here is the code i used :</p>
  
  <pre><code>    @Override
      public void onStart(Intent intent, int startId) {
          locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          listener = new MyLocationListener();
          locationManager.requestLocationUpdates(
                  LocationManager.NETWORK_PROVIDER, 4000, 0, listener);
          locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                  4000, 0, listener);
      }
  
  
  
  
      public class MyLocationListener implements LocationListener {
  
          public void onLocationChanged(final Location loc) {
              Log.i("**************************************", "Location changed");
              if (isBetterLocation(loc, previousBestLocation)) {
                  loc.getLatitude();
                  loc.getLongitude();
  
  //              
  //              intent.putExtra("Latitude", loc.getLatitude());
  //              intent.putExtra("Longitude", loc.getLongitude());
  //              intent.putExtra("Provider", loc.getProvider());
  //              
  //              sendBroadcast(intent);
  
              }
          }
  
          public void onProviderDisabled(String provider) {
              Toast.makeText(getApplicationContext(), "Gps Disabled",
                      Toast.LENGTH_SHORT).show();
          }
  
          public void onProviderEnabled(String provider) {
              Toast.makeText(getApplicationContext(), "Gps Enabled",
                      Toast.LENGTH_SHORT).show();
          }
          public void onStatusChanged(String provider, int status, Bundle extras) {
  
          }
  
      }
  }
  </code></pre>
  
  <p>I dont know how to run the service background every fifteen minutes of interval..
  I want to start an aysnctask when i get fresh location updates.Is the service or the alarm manager is the best option.
      If i start a service,can i start an asynctask to post locations to the server.?</p>