title: Return response of Volley of Android
body: <p>I have written a function that makes an HTTP request and the response stores in a Bundle to subsequently initialize an activity.</p>
  
  <pre><code>public static void communicate(final Context context, String url, final String typeResponse, final Intent intent) {
      RequestQueue queue = Volley.newRequestQueue(context);
  
      RequestFuture&lt;String&gt; future = RequestFuture.newFuture();
      StringRequest stringRequest = new StringRequest(Request.Method.POST, BASE_URL + url, new Response.Listener&lt;String&gt;() {
          @Override
          public void onResponse(String response) {
              //Toast.makeText(context, response, Toast.LENGTH_SHORT).show();
              Bundle bundle = new Bundle();
              switch (typeResponse) {
                  case "text":
                      bundle.putString("response", response);
                      break;
                  case "json":
                      try {
                          JSONObject jsonObject = new JSONObject(response);
                          JSONArray names = jsonObject.names();
                          for (int i = 0; i &lt; names.length(); i++) {
                              //Toast.makeText(context, names.getString(i), Toast.LENGTH_SHORT).show();
                              bundle.putString(names.getString(i), jsonObject.getString(names.getString(i)));
                          }
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                      break;
              }
  
              intent.putExtras(bundle);
              context.startActivity(intent);
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              Toast.makeText(context, "error", Toast.LENGTH_SHORT).show();
          }
      }) {
          @Override
          protected Map&lt;String, String&gt; getParams() {
              Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
              params.put("test", "hi!!");
              return params;
          }
      };
      queue.add(stringRequest);
  }
  </code></pre>
  
  <p>But I want return the Bundle object for use that function like this:</p>
  
  <pre><code>Bundle myBundle = communicate('httl://qwe.asd', 'json')
  </code></pre>
  
  <p>How can I to modifier my function?</p>
  
  <p>Thanks.</p>