title: Getting location when button is clicked
body: <p>I am trying to get the app to send a web service call using the GPS coordinates when the user clicks on a button.</p>
  
  <p>When I click on a button, it creates a <code>locationManager</code> and <code>requestLocationUpdates</code> and sends the web service with the GPS coordinates retrieved from the <code>LocationManager</code> and then <code>removelistener</code> in the <code>AsyncTask</code>.</p>
  
  <p>The problem is that when I click the button it's not able to get the location every time as the <code>LocationManager</code> is not able to get the GPS coordinates instantly, but only in the <code>onLocationChanged</code> callback. How can I wait for this callback without blocking the UI?</p>
  
  <p>I have tried to use <code>Looper</code> within the <code>AsyncTask</code> and got it working but it crashes the app when I click on the button for the sixth time.</p>