title: Changing Volley call to AsyncTask
body: <p>I would like to change this function to be able to wait until is done, cause when I use it to log in via API, it takes some time to get answer and my app now says login failed cause it doesn't wait for answer.</p>
  
  <p>I know I need to change my class to extends <code>AsyncTask</code>, but what I don't know ho to change this function to <code>doInBackground()</code>, because in every tutorial they send to <code>doInBackground</code> only URLs and returns string, but I need to send to function also request type, body and <code>callbackID</code>.</p>
  
  <pre><code>private void createCall(int type, String url, JSONObject data, final int callback) {
      JsonObjectRequest jsonRequest = new JsonObjectRequest(type, url,data,
              new Response.Listener&lt;JSONObject&gt;() {
                  @Override
                  public void onResponse(JSONObject response) {
                      Log.d("Response", response.toString());
                      try {
                          callback(response, callback);
                      } catch (Exception e){
                          Log.d("API callback error", e.getMessage());
                      }
  
                  }
              },
              new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      Log.d("Error response", error.toString());
                  }
              }
      );
      queue.add(jsonRequest);
  }
  </code></pre>
  
  <p>I would like to be able to wait until I get any result from api call.</p>