title: android while loop alternative
body: <p>This is my first Android application and I am finding troubles with while loop, I am trying to use a while loop on my Android application but the application freezes. </p>
  
  <p>What I'm trying to do is track the user location (using onlocationChanged) and keep querying on the location until the query returns a result. It's a GIS application so I am going to describe the application behavior:
  the application keeps tracking the user position using a listener "onLocationChangedListener" and store it in a variable "myPosition". I am using a boolean"noResults=true". I will use a method "query(myPosition)" in the while loop, this method has a callback that when a result is found, and changes a boolean "noResults" to false.  the loop will keep on until "noResults" is false (that means query's callback changed the boolean's value) </p>
  
  <p>, here's what I did:</p>
  
  <pre><code>while(noResults)
  {
  //myPosition keeps changing 
        query(myPosition);
  //query has a callback that when a result is found it changes noResults to false
  }
  </code></pre>