title: progress dialog does not dismiss
body: <p>what I am trying to do is get the location of the user after they click a button, called location_Button, and then show a box that shows some info about their location. I have tried like this: </p>
  
  <pre><code>Button location_Button=(Button) findViewById(R.id.location_button);
      location_Button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              // Define a listener that responds to location updates
             progressDialog = ProgressDialog.show(Settings.this, "", "Loading...");
  
              final LocationListener locationListener = new LocationListener() {
  
                  public void onLocationChanged(Location location) {
                      // Called when a new location is found by the network location provider.
  
                      lat =location.getLatitude();
                      lon = location.getLongitude();
                      try{
  
                          addresses=(geocoder.getFromLocation(lat, lon, 1));
                          if (addresses.size() &gt; 0) {
                              String city = addresses.get(0).getAddressLine(1);
                              String id = city.substring(0,city.length()-5);
                              String state1=String.valueOf(id.charAt(id.length()-3));
                              String state2=String.valueOf(id.charAt(id.length()-2));
                              String STATE = state1+state2;
  
                              locationManager.removeUpdates(this);
                              progressDialog.dismiss();
  
                              //alert dialog is established and displayed here
  
  
  
                          }
                          else {
                              //tv.setText("Oops...");
                          }
  
                      }catch(IOException e){
                          e.printStackTrace();
                      }
  
                  }
  
                  public void onStatusChanged(String provider, int status, Bundle extras) {}
  
                  public void onProviderEnabled(String provider) {}
  
                  public void onProviderDisabled(String provider) {}
              };
  </code></pre>
  
  <p>And the issue is that the progress dialog is never dismissed. without the progress dialog when the button is pressed it searches and then shows the box, with the progress dialog it continues to say loading and is never dismissed. my goal is to have the progress dialog dismissed after the location is established, also the alert dialog should pop up but it is not. is the location of the progress dialog incorrect? </p>