title: Retrieving location updates in Service in Android
body: <p>I try to retrieve Location updates in Service by network provider, but the updates doesn,t perform. My code looks like this:</p>
  
  <pre><code>public class TimeService extends Service{
  
  LocationManager lm;
  LocationListener ll = new LocationListener()
  {
  
      @Override
      public void onLocationChanged(Location location) {
  
          double latitude = location.getLatitude();
          double longtitude = location.getLongitude();
  
          Intent inte =new Intent( TimeService.this, myAppWidgetProvider.class);
          inte.setAction("action_location");
          inte.putExtra("lat", latitude);
          inte.putExtra("long", longtitude);
  
          PendingIntent pinte = PendingIntent.getBroadcast(TimeService.this, 0, inte, 0);
  
          try {
              pinte.send();
          } catch (CanceledException e) {
              // TODO Auto-generated catch block
              Log.d("sendPIException", ":-(");
          }
  
          Log.d("locReceived", "onLochanged");
  
      }
  
      @Override
      public void onProviderDisabled(String provider) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onProviderEnabled(String provider) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onStatusChanged(String provider, int status,
              Bundle extras) {
          // TODO Auto-generated method stub
  
      }
  
  };
  </code></pre>
  
  <p>Log "locReceived" in onLocationChanged doesn't appear i logcat
  Following code responsible for Location in my Service, too:</p>
  
  <pre><code>@Override
      public int onStartCommand(Intent intent, int flags, int startId) {
          this.registerReceiver(br, new IntentFilter(Intent.ACTION_TIME_TICK));
          lm =(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
          lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, ll);
          return super.onStartCommand(intent, flags, startId);
      }
  </code></pre>
  
  <p>What's wrong in my code?</p>