title: How can I return value from function onResponse of Volley?
body: <pre><code>public class getString  {
  String tag_string_req = "string_raq";
  String url = "http://10.0.2.2/eat/locations/index.json";
  String result="";
  
  public String get_String() {
      StringRequest strReq = new StringRequest(Request.Method.GET, url, new Response.Listener&lt;String&gt;() {
          @Override
          public void onResponse(String response) {
              result=response;
              System.out.println(response);
              ;
  
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError volleyError) {
              System.out.println(volleyError.getMessage());
          }
      });
      AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
      return result;
  }}
  </code></pre>
  
  <p>I would to build an object of getString and call get_String in other fields. But it seems that it is hard to get the result out from the onResponse. I know it cannot work in this current way. Could anyone help me to settle this problem?</p>