Aquí está el código. lista es una variable global.
ArrayList<LatLng> list = new ArrayList<LatLng>(); public void addCoordinate(double a, double b){ list.add(new LatLng(a,b)); } public ArrayList<LatLng> readItems(int ignore) throws JSONException { addCoordinate(2.0,2.0); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, showUrl, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { System.out.println(response.toString()); try { JSONArray records = response.getJSONArray("locations"); for (int i = 0; i < records.length(); i++) { JSONObject locations = records.getJSONObject(i); double latitude = locations.getDouble("Latitude"); double longitude = locations.getDouble("Longitude"); // double lat = Double.parseDouble(latitude); // double lng = Double.parseDouble(longitude); list.add(new LatLng(latitude,longitude)); } addCoordinate(3.0,3.0); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { System.out.append(error.getMessage()); } }); //requestQueue.add(jsonObjectRequest); addCoordinate(1.0,1.0); return list; }Solo devuelve los dos valores cuando se llama a getCoordinate (el 1,1 y el 2,2), pero se salta el (3,3). Si alguien tiene una solucion se lo agradeceria gracias.
(3,3) se agregará solo después de llamar a onResponse.