I'm using Volley to hit a REST API. Most of my calls return 200, if it returns 400, 401, or 409, I pass back a json response with different error messages as to what's wrong. I've been looking at the parseNetworkRequest, but I'm not really understanding it.
Here's my JsonArrayRequest. It's only supposed to return a status code. No message, which will probably change to adding a json message on 400 or 401
JsonArrayRequest postVerification = new JsonArrayRequest(url,amountArray,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
realm = Realm.getInstance(getApplicationContext());
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.where(AccountsModel.class).beginsWith("actId", accountId).findFirst().setActverified("true");
}
});
dismissDialog();
updateView(); }
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i("error", "Error: " + error.getMessage());
dismissDialog();
Toast message = Toast.makeText(getApplicationContext(),"Unable to verify account at this time", Toast.LENGTH_SHORT);
message.show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json");
Log.i("Auth", "Bearer " + NetworkEngine.access_token);
headers.put("Authorization", auth);
return headers;
}
@Override
public int getMethod() {
return Method.POST;
}
@Override
protected Response<T> parseNetworkResponse(
NetworkResponse response) {
try {
String json = new String(response.data,
HttpHeaderParser.parseCharset(response.headers));
return Response.success(json,),
HttpHeaderParser.parseCacheHeaders(response));
} catch(Exception e){}
}
};
I have an error on the parseNetworkResponse line
error: cannot find symbol
protected Response<T> parseNetworkResponse(
When I hover over the Response it says it's trying to use an incompatible return type. I really have no idea what to do from here. Not sure what to put in the Response.sucess() or how to actually get the status code. Any help would be appreciated.