title: How to stop automatic updates of Location
body: <p>I'm creating an app which updates the location(lat,long) everytime a button is clicked.
  I have set an OnClickListener on the button which calls this method - </p>
  
  <pre><code> void getLocation() {
      try{
          locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          //Default minTime = 5000, minDistance = 5
          locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this);
      }
      catch (SecurityException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>But the problem is that the location keeps updating itself, in small time periods. I want the location to stay the same and only update itself when the button is pressed. What modifications must I make to do that?</p>
  
  <p>Here is the onLocationChanged() method for reference - </p>
  
  <pre><code>@Override
  public void onLocationChanged(Location location) {
  
      locationText.setText("Current Location: "+ location.getLatitude() + " , " + location.getLongitude());
  }
  </code></pre>
  
  <p>And also, sometimes it shows the location within a second, while other times it takes 10seconds. Any reason/solution for that?</p>