I am struggling my way through my first android application which is processing weather satellite data. I am using JSON to retrieve times for tile images from a remote server. Due to my lack of experience with java, I cannot get the jResponse so other portions of the application can use the data. Is there a way to get the jResponse (JSONArray) out of the on response method? When I try and change the method to return a JSONArray it undoes the override. I am quite stuck and would really appreciate any help.
public JSONArray getJson(final int i,String sectorName){
times = new JSONArray();
String url = "https://storage.googleapis.com/satsquatch-tiles-dev/GOES16_"+String.format("%02d",i)+"_"+sectorName+".json";
final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("test", "Success");
try {
JSONArray jResponse = response.getJSONArray("times");
for (int count = 0; count < jResponse.length(); count++){
Log.d("Array_times",jResponse.get(count).toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("test", "JSON Request Failure Check URL!");
}
});
//add request to queue
queue.add(jsonObjectRequest);
return times;