Вернуть ответ JSONObject в методе - PullRequest
0 голосов
/ 08 мая 2020

Я хочу вернуть результат или ответ JSONObject, но ответ не может быть возвращен. Как это сделать?

private String requestJSON(String stringURI) {

     JsonObjectRequest objectRequest = new JsonObjectRequest(Request.Method.GET, stringURI, null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                     //Here I want to return this  response  at the end of this method
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                });

        requestQueue.add(objectRequest);


     return response.toString;
    }
...