title: Location Listener In Service
body: <p>I need a service in my reminder program to check location repeatedly and I'm doing that with this code but I get force close when service started:</p>
  
  <pre><code>@Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
      ll = new Mylocationlistener();
      checkPermission("android.permission.ACCESS_FINE_LOCATION",1,0);
      lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
      return START_STICKY;
  }
  
  private class Mylocationlistener implements LocationListener {
      @Override
      public void onLocationChanged(Location location) {
          if (location != null) {
              Toast.makeText(getBaseContext(), "Location changed" + location.getLatitude() + location.getLongitude(), Toast.LENGTH_SHORT).show();
          }
      }
  
      @Override
      public void onStatusChanged(String provider, int status, Bundle extras) {
  
      }
  
      @Override
      public void onProviderEnabled(String provider) {
  
      }
  
      @Override
      public void onProviderDisabled(String provider) {
  
      }
  }
  </code></pre>