Q:

Having trouble using strings outside of Volley request onResponse

I have a search dialog in my MainActivity that when used sends the user query to a SearchActivity. From there I send a JSON request using volley and then deserialize the JSON using GSON. all of this is working good and I can even print, for an example, the latitude value of my request using:
System.out.println(cam[0].getLat());

However, all of this must be done within the onResponse of the volley request. I'm trying to send some of the values back to my MainActivity which I know how to do already. I just need to know how to store some of the strings so that I can access them outside of onResponse.
Method that sends request and deserializes it:
private void fetchJsonResponse() {

    JsonArrayRequest req = new JsonArrayRequest(myUrl, new Response.Listener<JSONArray>() {

        @Override
        public void onResponse(JSONArray response) {

            Gson gson = new Gson();
            String nominatimData = response.toString();
            NominatimModel[] cam = gson.fromJson(nominatimData, NominatimModel[].class);

            // i'd like to using cam[0].getLat(); outside of this method

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            // TODO Auto-generated method stub

        }
    });
    mRequestQueue.add(req);
}

NominatimModel.java
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

public class NominatimModel {

@SerializedName("place_id")
@Expose
private String placeId;
@Expose
private String licence;
@SerializedName("osm_type")
@Expose
private String osmType;
@SerializedName("osm_id")
@Expose
private String osmId;
@Expose
private List<String> boundingbox = new ArrayList<String>();
@Expose
private String lat;
@Expose
private String lon;
@SerializedName("display_name")
@Expose
private String displayName;
@SerializedName("class")
@Expose
private String _class;
@Expose
private String type;
@Expose
private Double importance;
@Expose
private String icon;

/**
 * @return The placeId
 */
public String getPlaceId() {
    return placeId;
}

/**
 * @param placeId The place_id
 */
public void setPlaceId(String placeId) {
    this.placeId = placeId;
}

/**
 * @return The licence
 */
public String getLicence() {
    return licence;
}

/**
 * @param licence The licence
 */
public void setLicence(String licence) {
    this.licence = licence;
}

/**
 * @return The osmType
 */
public String getOsmType() {
    return osmType;
}

/**
 * @param osmType The osm_type
 */
public void setOsmType(String osmType) {
    this.osmType = osmType;
}

/**
 * @return The osmId
 */
public String getOsmId() {
    return osmId;
}

/**
 * @param osmId The osm_id
 */
public void setOsmId(String osmId) {
    this.osmId = osmId;
}

/**
 * @return The boundingbox
 */
public List<String> getBoundingbox() {
    return boundingbox;
}

/**
 * @param boundingbox The boundingbox
 */
public void setBoundingbox(List<String> boundingbox) {
    this.boundingbox = boundingbox;
}

/**
 * @return The lat
 */
public String getLat() {
    return lat;
}

/**
 * @param lat The lat
 */
public void setLat(String lat) {
    this.lat = lat;
}

/**
 * @return The lon
 */
public String getLon() {
    return lon;
}

/**
 * @param lon The lon
 */
public void setLon(String lon) {
    this.lon = lon;
}

/**
 * @return The displayName
 */
public String getDisplayName() {
    return displayName;
}

/**
 * @param displayName The display_name
 */
public void setDisplayName(String displayName) {
    this.displayName = displayName;
}

/**
 * @return The _class
 */
public String getClass_() {
    return _class;
}

/**
 * @param _class The class
 */
public void setClass_(String _class) {
    this._class = _class;
}

/**
 * @return The type
 */
public String getType() {
    return type;
}

/**
 * @param type The type
 */
public void setType(String type) {
    this.type = type;
}

/**
 * @return The importance
 */
public Double getImportance() {
    return importance;
}

/**
 * @param importance The importance
 */
public void setImportance(Double importance) {
    this.importance = importance;
}

/**
 * @return The icon
 */
public String getIcon() {
    return icon;
}

/**
 * @param icon The icon
 */
public void setIcon(String icon) {
    this.icon = icon;
}

}
Example JSON:
[{"place_id":"115063146","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"258132245","boundingbox":["29.7156836","29.7278762","-95.3520172","-95.3349753"],"lat":"29.7214917","lon":"-95.3440202128152","display_name":"University of Houston, 4800, Calhoun Road, Houston, Harris County, Texas, 77004, United States of America","class":"amenity","type":"university","importance":0.84733963787614,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/education_university.p.20.png"}]

I'm fairly new to java and Android development so if someone can help me out a bit i'd appreciate it and if I left out any information let me know. 

A:

Figured I'd answer this question now that time has passed and I've learned a ton about Android, including how to accomplish this. So I had all my models implement Serializable, and then just bundled the response data and passed it to the other activity. I later, got rid of this and was able to accomplish everything I needed within the onResponse.
I'd steer away from using Serializable if you must do what I was trying to accomplish and instead check out the Parcelable interface, it has the advantage of being faster.
Hope this helps to anyone who comes across this question!

