title: progress dialog with async task issues
body: <p>what I am trying to do is use async task to display a progress dialog while my app searches for their location. after their location is found it should show an alert dialog with some info. however i am not 100% sure how to do this. this is what i have in LocationChanged.java:</p>
  
  <pre><code>@Override
  protected Void doInBackground( Void... params ) {
      final LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
      geocoder = new Geocoder(context, Locale.getDefault());
      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();
              //TextView tv = (TextView) findViewById(R.id.tv3);
              try{
                  addresses=(geocoder.getFromLocation(lat, lon, 1));
                  if (addresses.size() &gt; 0) {
                      // String address = addresses.get(0).getAddressLine(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));
                      STATE = state1+state2;
                      //String country = addresses.get(0).getAddressLine(2);
                      //tv.setText(STATE);
                      progressDialog.dismiss();
                      locationManager.removeUpdates(this);
                  }
                  else {
                      //tv.setText("Oops...");
                  }
  
              }catch(IOException e){
                  e.printStackTrace();
              }
  
          }
  </code></pre>
  
  <p>and this is the logcat when it runs: </p>
  
  <pre><code>07-08 17:26:21.456: ERROR/AndroidRuntime(2755): FATAL EXCEPTION: AsyncTask #1
      java.lang.RuntimeException: An error occured while executing doInBackground()
      at android.os.AsyncTask$3.done(AsyncTask.java:299)
      at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
      at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
      at java.util.concurrent.FutureTask.run(FutureTask.java:137)
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
      at java.lang.Thread.run(Thread.java:864)
      Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
      at android.os.Handler.&lt;init&gt;(Handler.java:121)
      at android.location.LocationManager$ListenerTransport$1.&lt;init&gt;(LocationManager.java:209)
      at android.location.LocationManager$ListenerTransport.&lt;init&gt;(LocationManager.java:209)
      at android.location.LocationManager._requestLocationUpdates(LocationManager.java:687)
      at android.location.LocationManager.requestLocationUpdates(LocationManager.java:512)
      at com.nick.whatsthetip.LocationChanged.doInBackground(LocationChanged.java:121)
      at com.nick.whatsthetip.LocationChanged.doInBackground(LocationChanged.java:24)
      at android.os.AsyncTask$2.call(AsyncTask.java:287)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
      ... 5 more
  07-08 17:26:21.716: ERROR/EmbeddedLogger(696): App crashed! Process:    com.nick.whatsthetip
  07-08 17:26:21.716: ERROR/EmbeddedLogger(696): App crashed! Package: com.nick.whatsthetip v5 (1.1.0)
  07-08 17:26:21.987: ERROR/WindowManager(2755): Activity com.nick.whatsthetip.Settings    has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41075198 that was originally added here
      android.view.WindowLeaked: Activity com.nick.whatsthetip.Settings has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41075198 that was originally added here
      at android.view.ViewRootImpl.&lt;init&gt;(ViewRootImpl.java:468)
      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:419)
      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:351)
      at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:171)
      at android.view.Window$LocalWindowManager.addView(Window.java:558)
      at android.app.Dialog.show(Dialog.java:282)
      at android.app.ProgressDialog.show(ProgressDialog.java:116)
      at android.app.ProgressDialog.show(ProgressDialog.java:99)
      at android.app.ProgressDialog.show(ProgressDialog.java:94)
      at com.nick.whatsthetip.LocationChanged.onPreExecute(LocationChanged.java:49)
      at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
      at android.os.AsyncTask.execute(AsyncTask.java:534)
      at com.nick.whatsthetip.Settings$3.onClick(Settings.java:119)
      at android.view.View.performClick(View.java:4102)
  </code></pre>