Implementing my LoginActivity.java , I am installing another + file class, called AuthClientone that uses Volley heavily. UserLoginTaskmust be returned Booleanfrom doInBackgroundso that the remote login call succeeds.
So, following Can I execute a synchronous request with volley? I setup:
void login(final HashMap<String, String> data,
Response.Listener<JSONObject> listener,
Response.ErrorListener errorListener) {
JsonObjectRequest req = new JsonObjectRequest(
api_prefix + "/auth", new JSONObject(data), listener, errorListener
);
queue.add(req);
}
boolean loginResponseHandler(RequestFuture<VolleyError> err_future,
RequestFuture<JSONObject> future) {
try {
VolleyError err_response = err_future.get();
JSONObject response = future.get();
System.out.println("response.toString() = " + response.toString());
return true;
} catch (InterruptedException | ExecutionException e) {
System.err.println("e = " + e.toString());
return false;
} catch (Exception e) {
System.err.println("Exception::e = " + e.toString());
throw e;
}
}
@Override
protected Boolean doInBackground(Void... params) {
RequestFuture<JSONObject> future = RequestFuture.newFuture();
RequestFuture<VolleyError> err_future = RequestFuture.newFuture();
login(, err_future, future);
return loginResponseHandler(err_future, future);
}
But looking at the debug log, I get an error (from somewhere else, and not where I am debugging):
08-24 23: 17: 13.228 7255-7288 E / Volley: [177] BasicNetwork.performRequest: Unexpected 400 response code for http://192.168.5.3 {003/v1/api/auth
How should I handle errors? . Also there is a reference scaffold for work?