title: How to return a class to a onPostExecute?
body: <p>Update, please see below.</p>
  
  <p>How do I return my class LocationData and my ArrayList listOfObjects to the onPostExecute()? I want to use it in my UI and right now it is in the background in an AsyncTask. Also I want to add markers with:</p>
  
  <pre><code>mMap.addMarker(new MarkerOptions()
      .position(new LatLng(lati, longi))
      .title(name));
  </code></pre>
  
  <p>so that I can add each new location to the map after each loop.</p>
  
  <p>Do I place the above in the onPostExecute after returning the LocationData class?</p>
  
  <pre><code>    try {
  
          String apples = endpoint.listContactInfo().execute().toString();
  
          JSONObject jObject = new JSONObject(apples);
  
          JSONArray jsonArr = jObject.getJSONArray("items");
  
          for (int i = 0; i &lt; jsonArr.length(); i++) {
              JSONObject jsonObj1 = jsonArr.getJSONObject(i);
  
              // Storing each json item in variable
              String id = jsonObj1.getString(TAG_ID);
              String nameFirst1 = jsonObj1.getString(TAG_FIRSTNAME);
              String nameLast1 = jsonObj1.getString(TAG_LASTNAME);
              String emailAddress1 = jsonObj1.getString(TAG_EMAIL);
              String streetAddress1 = jsonObj1.getString(TAG_ADDRESS);
              String phone1 = jsonObj1.getString(TAG_PHONE);
  
              // test to see if made it to string
              Log.d("YOUR_TAG", "First Name: " + nameFirst1 + " Last Name: "
                      + nameLast1);
  
              address = coder.getFromLocationName(streetAddress1, 5);
  
              Address location1 = address.get(0);
  
              // SET LAT LNG VALUES FOR MARKER POINT
  
              lati = location1.getLatitude();
              longi = location1.getLongitude();
  
              Log.d("Location", "Location:" + lati + " " + longi);
  
              class LocationData {
                  private double lat;
                  private double longitude;
                  private String name;
  
                  public LocationData(double lat, double longitude,
                          String name) {
                      this.lat = lat;
                      this.longitude = longitude;
                      this.name = name;
                  }
  
                  public void setLat(double lat) {
                      this.lat = lat;
                  }
  
                  public void setLongitude(double longitude) {
                      this.longitude = longitude;
                  }
  
                  public double getLat() {
                      return lat;
                  }
  
                  public double getLongitude() {
                      return longitude;
                  }
  
                  public void setName(String name) {
                      this.name = name;
                  }
  
                  public String getName() {
                      return name;
                  }
  
              }
  
              ArrayList&lt;LocationData&gt; listOfObjects = new ArrayList&lt;LocationData&gt;();
  
              listOfObjects.add(new LocationData(lati, longi, nameFirst1));
  
          }
  
      } catch (IOException e) {
          e.printStackTrace();
      } catch (JSONException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      return (long) 0;
  
  }
  
  // WHAT DO I PUT HERE TO RETURN LocationData Class here
  // ADD MARKER TO MAP UI
  protected void onPostExecute() {
  
      // mMap.addMarker(new MarkerOptions()
      // .position(new LatLng(lati, longi))
      // .title("Hello world"));
  </code></pre>
  
  <p>This may seem elementary but I've created this method:
       public ArrayList getLocationData() {</p>
  
  <pre><code>                                 ArrayList&lt;LocationData&gt; listOfObjects = new ArrayList&lt;LocationData&gt;();
  
                                   listOfObjects.add(new LocationData(lati, longi, nameFirst1));
  
                                   return listOfObjects;
                               }
  </code></pre>
  
  <p>within my LocationData class. I then placed LocationData.getLocationData(); with the onPostExecute and I get the LocationData can't be resolved. The code together looks like this at the moment:</p>
  
  <pre><code> try {
  
      String apples = endpoint.listContactInfo().execute().toString();
  
      JSONObject jObject = new JSONObject(apples);
  
      JSONArray jsonArr = jObject.getJSONArray("items");
  
       for(int i =0 ; i&lt;jsonArr.length() ;i++ ){
           JSONObject jsonObj1 = jsonArr.getJSONObject(i);
  
  
                      // Storing each json item in variable
                      String id = jsonObj1.getString(TAG_ID);
                      final String nameFirst1 = jsonObj1.getString(TAG_FIRSTNAME);
                      String nameLast1 = jsonObj1.getString(TAG_LASTNAME);
                      String emailAddress1 = jsonObj1.getString(TAG_EMAIL);
                      String streetAddress1 = jsonObj1.getString(TAG_ADDRESS);
                      String phone1 = jsonObj1.getString(TAG_PHONE);
  
                      //test to see if made it to string
                      Log.d("YOUR_TAG", "First Name: " + nameFirst1 + " Last Name: " + nameLast1);
  
                         address = coder.getFromLocationName(streetAddress1,5);
  
                          Address location1 = address.get(0);
  
                          // SET LAT LNG VALUES FOR MARKER POINT
  
                       lati = location1.getLatitude();
                           longi = location1.getLongitude();
  
                           Log.d("Location", "Location:" + lati + " " +  longi);
  
  
                         class LocationData {
                               private double lat;
                               private double longitude;
                               private String name;
  
                               public LocationData(double lat, double longitude, String name) {
                                   this.lat = lat;
                                   this.longitude = longitude;
                                   this.name = name;
                               }
  
                               public void setLat(double lat) {
                                   this.lat = lat;
                               }
  
                               public void setLongitude(double longitude) {
                                   this.longitude = longitude;
                               }
  
                               public double getLat() {
                                   return lat;
                               }
  
                               public double getLongitude() {
                                   return longitude;
                               }
  
                               public void setName(String name) {
                                     this.name = name;
                                  }
  
                               public String getName() {
                                   return name;
  
  
  
                                  }
  
                               public ArrayList&lt;LocationData&gt; getLocationData() {
  
                                   ArrayList&lt;LocationData&gt; listOfObjects = new ArrayList&lt;LocationData&gt;();
  
                                   listOfObjects.add(new LocationData(lati, longi, nameFirst1));
  
                                   return listOfObjects;
                               }
  
                               }
  
       }
  
      } catch (IOException e) {
      e.printStackTrace();
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
        return (long) 0;
  
  
      }
      //WHAT DO I PUT HERE TO RETURN LocationData Class here
           // ADD MARKER TO MAP UI
      protected void onPostExecute(Long result ) {
  
                    //CANT BE RESOLVED
          LocationData.getLocationData();
  
          //mMap.addMarker(new MarkerOptions()
          //.position(new LatLng(lati, longi))
          // .title("Hello world"));
  </code></pre>
  
  <p>Here are my changes based upon @Sustain recommendations. I seem to not be getting any map markers now. Anyone see anything?</p>
  
  <pre><code>public class FinderActivity extends Activity implements LocationListener  {
  
  
  GoogleMap mMap;
  Location myLocation;
  EditText length;
  String lengthString;
  LocationManager locationmanager;
  double lati;
  double longi;
  String nameFirst1;
  //Spinner s;
  
     List&lt;Address&gt; address;
     Geocoder coder = new Geocoder(this);
  private static final String TAG_ID = "id";
  private static final String TAG_FIRSTNAME = "nameFirst";
  private static final String TAG_LASTNAME = "nameLast";
  private static final String TAG_EMAIL = "emailAddress";
  private static final String TAG_ADDRESS = "streetAddress";
  private static final String TAG_STATE = "state";
  
  private static final String TAG_PHONE = "phone";
  JSONArray contacts = null;
  
  
  private static class LocationData {
       private double lat;
       private double longitude;
       private String name;
  
       public LocationData(double lat, double longitude, String name) {
           this.lat = lat;
           this.longitude = longitude;
           this.name = name;
       }
  
       public void setLat(double lat) {
           this.lat = lat;
       }
  
       public void setLongitude(double longitude) {
           this.longitude = longitude;
       }
  
       public double getLat() {
           return lat;
       }
  
       public double getLongitude() {
           return longitude;
       }
  
       public void setName(String name) {
             this.name = name;
          }
  
       public String getName() {
           return name;
  
          }
  
       }
  
  @SuppressLint("NewApi")
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.maps);
      mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
      if (mMap!= null) {
  
          mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
  
  
          mMap.setMyLocationEnabled(true);
          mMap.animateCamera(CameraUpdateFactory.zoomBy(17));
  
          }
  
      LocationManager locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);
      Criteria cr = new Criteria();
      String provider = locationmanager.getBestProvider(cr, true);
  
      Location location = locationmanager.getLastKnownLocation(provider);
  
      locationmanager.requestLocationUpdates(provider, 20, 0, (LocationListener) this);
  
      mMap.moveCamera(CameraUpdateFactory.newLatLng((new LatLng(location.getLatitude(), location.getLongitude()))));
  
  
      new EndpointsTask().execute(getApplicationContext());
  
  }
  
  public class EndpointsTask extends AsyncTask&lt;Context, LocationData, Long&gt; {
  
      private List&lt;LocationData&gt; locationList = new ArrayList&lt;LocationData&gt;();
  
      public Long doInBackground(Context... contexts) {
  
        Contactinfoendpoint.Builder endpointBuilder = new Contactinfoendpoint.Builder(
            AndroidHttp.newCompatibleTransport(),
            new JacksonFactory(),
            new HttpRequestInitializer() {
            public void initialize(HttpRequest httpRequest) { }
            });
    Contactinfoendpoint endpoint = CloudEndpointUtils.updateBuilder(
    endpointBuilder).build();
  
    try {
  
      String apples = endpoint.listContactInfo().execute().toString();
  
      JSONObject jObject = new JSONObject(apples);
  
      JSONArray jsonArr = jObject.getJSONArray("items");
  
       for(int i =0 ; i&lt;jsonArr.length() ;i++ ){
           JSONObject jsonObj1 = jsonArr.getJSONObject(i);
  
  
                      // Storing each json item in variable
                      String id = jsonObj1.getString(TAG_ID);
                      String nameFirst1 = jsonObj1.getString(TAG_FIRSTNAME);
                      String nameLast1 = jsonObj1.getString(TAG_LASTNAME);
                      String emailAddress1 = jsonObj1.getString(TAG_EMAIL);
                      String streetAddress1 = jsonObj1.getString(TAG_ADDRESS);
                      String phone1 = jsonObj1.getString(TAG_PHONE);
  
                      //test to see if made it to string
                      Log.d("YOUR_TAG", "First Name: " + nameFirst1 + " Last Name: " + nameLast1);
  
                         address = coder.getFromLocationName(streetAddress1,5);
  
                          Address location1 = address.get(0);
  
                          // SET LAT LNG VALUES FOR MARKER POINT
  
                       lati = location1.getLatitude();
                           longi = location1.getLongitude();
  
                           Log.d("Location", "Location:" + lati + " " +  longi);
  
                           LocationData data = new LocationData(lati, longi, nameFirst1);
                           locationList.add(data);
                           publishProgress(data);
  
       }
  
      } catch (IOException e) {
      e.printStackTrace();
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
        return (long) 0;
  
      }
  
      protected void onProgressUpdate(LocationData data) {
          // Add Marker on Map using data. This is called by
          // publishProgress(LocationData) on the UI Thread.
          mMap.addMarker(new MarkerOptions()
          .position(new LatLng(lati, longi))
           .title(nameFirst1));
  
          Log.d("bananas", lati + longi + nameFirst1);
      }
  
      //WHAT DO I PUT HERE TO RETURN LocationData Class here
           // ADD MARKER TO MAP UI
      protected void onPostExecute() {
  
      }
  
      }
  </code></pre>