title: Android: How to timeout GPS trying to find a lock?
body: <p>Here are snippets of my code:</p>
  
  <pre><code>private class NoGpsLock implements Runnable {
      public void run() {
        if (gps == null) {
          Toast toast = Toast.makeText(getApplicationContext(), "Unable to find GPS lock", Toast.LENGTH_LONG);
          toast.show();
          if (locManager != null) {
            locManager.removeUpdates(locListener);
          }
        }
      }
    }
  </code></pre>
  
  <p>Called by</p>
  
  <pre><code>try {
    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DIST, locListener);
  } catch (Exception ex) {
  }
  Handler gpsHandler = new Handler();
  gpsHandler.postDelayed(new NoGpsLock(), 15000); //15seconds
  </code></pre>
  
  <p>From what I understand, <code>removeUpdates()</code> is supposed to stop the GPS receiving updates. I tried this on the emulator and on 2 devices; on the emulator, it does stop the app from receiving further location changes. However, on the actual devices, the icon for "Receiving location data from GPS" keeps showing up and drains the battery (which I assume indicates that the app/phone keeps on looking for a location and unable to, since I'm indoors). How do I stop the GPS from trying to find a location?</p>
  
  <p>EDIT: I want my app to stop trying to find location after a period of time, and then maybe restart the GPS again later.</p>