How to wait for volley response to complete and then executing next method
<p>I am executing two methods in onCreateView hitSearchApi() and getSwipeImage().</p>

<p>Before getting the response from hitsearchApi method it is excuting getSwipeImage method.</p>

<p>I dont know how to wait for volley response to complete and then execute the getSwipeImage() method.</p>

<p>So I cant get the expected result.Anyone can help me with this.Thank You.</p>

<p><strong>MainActivity.java:</strong></p>

<pre><code>  @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.cards_fragment, container, false);

      hitSearchApi();

      getSwipeImage();

      Log.e("AUTH_ID",""+AUTH_ID);

      return rootView;

      }

 void hitSearchApi(){


      String getUserApi = Utils.BR_USERS;
      Log.e("GetUserSearchApi", getUserApi);

     StringRequest request = new StringRequest(Request.Method.GET, getUserApi, new Response.Listener&lt;String&gt;() {

            @Override
            public void onResponse(String response) {
                if(response != null &amp;&amp; !response.startsWith("&lt;HTML&gt;")){
                    Log.e("onResponse", response);
                    dialog.dismiss();

                    try {
                        JSONArray jsonArr = new JSONArray(response);

                        for(int i = 0; i&lt;jsonArr.length();i++){

                            JSONObject jsonObj = jsonArr.getJSONObject(i);

                            AUTH_ID = jsonObj.getString("_id");

                      }

                    } catch (JSONException e) {
                        e.printStackTrace();
                        dialog.dismiss();
                    }

                }else{
                    dialog.dismiss();
                    toastShort(getActivity() , "Check Internet");
                }
            }
        }

 RequestQueue queue = Volley.newRequestQueue(getActivity());
        queue.add(request);
        queue.getCache().remove(getUserApi);



    }
</code></pre>