title: Variables lose data once Async Task task is executed
body: <p>I have a an activity with AsyncTask sub-classed.  I lose all my variables once the async task is executed.  I am stepping through my code in debug mode.  As soon as "MyAsync().execute()" finishes the "formatedURL" variable (and all the others) have no values. before that, they have the correct values. Then, for some odd reason, they lose the values.  Am i making a simple OO mistake or is garbage collection doing something i am not aware of.</p>
  
  <pre><code>public class NearbyList extends Activity {
  
      double lat;
      double lng;
      String restName;
      GPSHandling gps;
      String formatedURL;
      JSONObject jobject;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; listOfHM;
      ArrayList&lt;String&gt; listOfValues;
      String currentName;
      ListView lv;
      Context context;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.nearby_places_list);
  
          context = getApplicationContext();
          gps = new GPSHandling(this);
          lat = gps.getMyLatitude();
          lng = gps.getMyLongitude();
          restName ="";
          formatedURL = GooglePlacesStuff.placesURL(lat, lng, 16000, "food", restName, true);  //make a proper url. next step is to get a JSON object from this.
  
  
          new MyAsync().execute();// in order to run networking it must not be done in the UIthread. I use async task to take care of this in order to 
             //reduce the code of doing complex threading since this is a simple calculation
      }
          class MyAsync extends AsyncTask&lt;Void, Integer, Boolean&gt;{
              @Override
              protected Boolean doInBackground(Void... params) {
                  try {
                      jobject = GooglePlacesStuff.getTheJSON(formatedURL);
                      listOfHM = JSONextractor.getJSONHMArrayL(jobject);
                      // iterate through and get the names of the nearby restaurants from the array of hasmap strings
                      for(int i =0 ; i &lt; listOfHM.size() ;i++ ){
                          currentName = listOfHM.get(i).get(JSONextractor.TAG_NAME);
                          listOfValues.add(currentName);
                      }
                      return true;
                  } catch (Exception e){
                      Log.e("Nearby List Activity", "exception", e);
                      return false;}
              }
  
              @Override
              protected void onPostExecute(Boolean result){
                  super.onPostExecute(result);
                  if (result){
                      ListAdapter adapter = new SimpleAdapter(context, listOfHM, R.layout.nearby_places_list, new String[]{JSONextractor.TAG_NAME,
                              JSONextractor.TAG_VICINITY, JSONextractor.TAG_GEO_LOC_LAT}, new int[]{ R.id.name, R.id.vicinity, R.id.phone});
  
                      // adding data to listview
                      lv.setAdapter(adapter);
                  } else{
                      Toast.makeText(getApplicationContext(), "Need Internet &amp; GPS access for this to work", Toast.LENGTH_LONG).show();
                  }
                  gps.stopUsingGPS();  // stop using the gps after i get the list to save on resource
              }
          }
  }
  </code></pre>
  
  <p>Edit1:
  looks like it is trying to run "super.onCreate(Bundle savedInstanceState)" multiple times in the doinbackground() method</p>
  
  <p>Edit2: if i make the values static they don't get lost.  Its weird, even the variable "jobject" which is assigned inside the async task wont take an assignment unless its a static variable....  never seen anything like this</p>