title: Android: How to return async JSONObject from method using Volley?
body: <p>I'm trying to get back JSON object in the following way:</p>
  
  <pre><code>JSONObject jsonObject = http.makeRequest("GET", "https://api.twitter.com/1.1/search/tweets.json", null);
  </code></pre>
  
  <p>General method for processing all HTTP requests is following</p>
  
  <pre><code>public void makeRequest(String method, String url, Array params) {
  
      // Request a string response from the provided URL.
      JsonObjectRequest jsonObjReq = new JsonObjectRequest(getRequestMethod(method),
              url,
              new Response.Listener&lt;JSONObject&gt;() {
                  @Override
                  public void onResponse(JSONObject response) {
                      processResponse(Constants.Global.SUCCESS, null, response);
                  }
              },
              new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      try {
                          mStatusCode = error.networkResponse.statusCode;
                          VolleyLog.d(Constants.Global.ERROR, "Error: " + error.getMessage());
                          Logger.e(error.getMessage());
                      } catch (Exception e) {
                          Logger.e(e.getMessage());
                          mStatusCode = 0;
                      }
                      Logger.e(mStatusCode.toString());
                      processResponse(Constants.Global.ERROR, mStatusCode, null);
                  }
              });
      // Add tag to request for bulk cancelling
      //jsonObjReq.setTag()
      queue.add(jsonObjReq);
  }
  </code></pre>
  
  <p>And method for processing JSON result is following:</p>
  
  <pre><code>private JSONObject processResponse(String resultState, Integer httpStatusCode, JSONObject responseData) {
          try {
              // First check that result state is error or the success
              if (resultState.equals(Constants.Global.SUCCESS)) {
                  Logger.i("Response is success");
                  Logger.i(responseData.toString());
                  //TODO: ADD SUCCESS OBJECT CREATION
              }
              if (resultState.equals(Constants.Global.ERROR)) {
                  Logger.e("Response is error");
                  //TODO: ADD ERROR HANDLING AND ERROR OBJECT CREATION
              }
  
          } catch(Exception e) {
              e.printStackTrace();
              Logger.e(e.getMessage());
          }
          return responseData;
      }
  </code></pre>
  
  <p>I would like to ask how can i to get back JSONObject (first code snippet) in the async way.</p>
  
  <p>All requests are processed using the Volley library.</p>
  
  <p>Many thanks for any advice.</p>