Hi i have a volley request and i want to stop continue run app for get complete json from server and i want to use this tutorial Volley - http request in blocking way
but i do not understand where i must put , future, future
where i must put volleyRequestQueue.add(request);
where i must put
try {
JSONObject response = null;
while (response == null) {
try {
response = future.get(30, TimeUnit.SECONDS); // Block thread, waiting for response, timeout after 30 seconds
} catch (InterruptedException e) {
// Received interrupt signal, but still don't have response
// Restore thread's interrupted status to use higher up on the call stack
Thread.currentThread().interrupt();
// Continue waiting for response (unless you specifically intend to use the interrupt to cancel your request)
}
}
// Do something with response, i.e.
new SignUpResponseListener().onResponse(response);
} catch (ExecutionException e) {
// Do something with error, i.e.
new MyErrorListener().onErrorResponse(new VolleyError(e));
} catch (TimeoutException e) {
// Do something with timeout, i.e.
new MyErrorListener().onErrorResponse(new VolleyError(e));
}
and my volley request is :
JsonArrayRequest movieReq = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
int lage = (obj.getInt("flage"));
Toast.makeText(send_new_content.this, "flage "+lage, Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
}}}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}});
AppController.getInstance().addToRequestQueue(movieReq);