I'm retrieving the content of a invalid web address with volley, i.e. http://www.gigd32fdsu.com:
This is my test code:
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
final String url = "http://www.gigd32fdsu.com";
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener() {
#Override
public void onResponse(Object response) {
// Display the first 500 characters of the response string.
mTextView.setText("Response is: " + response.toString().substring(0, 500));
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
mTextView.setText("That didn't work! " + error.networkResponse.statusCode);
}
});
// Add the request to the RequestQueue.
queue.add(stringRequest);
When I run this code I receive the callback onResponse(String) with an error page from my ISP. How can I read the HTTP status code in order to detect that the web displaying is not correct?
Thanks
Simple solution is to override parseNetworkResponse in makeStringReq(), no need for another class:
private void makeStringReq() {
showProgressDialog();
StringRequest strReq = new StringRequest(Method.GET,
Const.URL_STRING_REQ,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.d(TAG, response.toString());
msgResponse.setText(response.toString());
hideProgressDialog();
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hideProgressDialog();
}
}) {
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
int mStatusCode = response.statusCode;
return super.parseNetworkResponse(response);
}
};
// Adding request to request queue
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
I will make the response from VinceStyling more complete. I'll tell you what I do.
Once you override this method, save the statusCode in your class.
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
statusCode=response.statusCode;
return super.parseNetworkResponse(response);
}
After that you should compare it with HttpURLConnection constants to act accordingly. For example:
int statusCode=webService.getStatusCode();
switch (statusCode){
case HttpURLConnection.HTTP_OK:
//do stuff
break;
case HttpURLConnection.HTTP_NOT_FOUND:
//do stuff
break;
case HttpURLConnection.HTTP_INTERNAL_ERROR:
//do stuff
break;
}
Just override the parseNetworkResponse method then take the statusCode value.
public class StrImplRequest extends StringRequest {
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
// take the statusCode here.
response.statusCode;
return super.parseNetworkResponse(response);
}
}
#VinceStyling 's answer is ok,
or you can extend Request class and do what you wanna do.
For example,
ServerStatusRequestObject extends Request {
private final Response.Listener mListener;
private String mBody = "";
private String mContentType;
public ServerStatusRequestObject(int method,
String url,
Response.Listener listener,
Response.ErrorListener errorListener) {
super(method, url, errorListener);
mListener = listener;
mContentType = "application/json";
if (method == Method.POST) {
RetryPolicy policy = new DefaultRetryPolicy(5000, 0, 5);
setRetryPolicy(policy);
}
}
#Override
protected Response parseNetworkResponse(NetworkResponse response) {
return Response.success(response.statusCode, HttpHeaderParser.parseCacheHeaders(response));
}
#Override
protected void deliverResponse(Object response) {
if (mListener != null) {
mListener.onResponse(response);
}
}
#Override
public byte[] getBody() throws AuthFailureError {
return mBody.getBytes();
}
#Override
public String getBodyContentType() {
return mContentType;
}
#Override
public int compareTo(Object another) {
return 0;
}
then in your response handler, you can still receive the whole messages from server.
Try it.
Related
I am trying to retrieve a JsonObject via GET request. When I set Breakpoints in my code I see that the count() method returns nothing. After that the onResponse method from the inner class gets called and the desired value gets retrieved.
I am calling the count() method inside the save() method. In order to create a JSONObject. The code creates the JSONObject before it retrieves the correct customer count.
I am using a custom requesQueue called AppController to queue the network request. I hope someone understands this strange behaviour.
#Override
public void save(Customer customer) throws JSONException {
int zw = count();
JSONObject obj = new JSONObject();
obj.put("customernumber", count + 1);
obj.put("name", customer.getName());
obj.put("lastname", customer.getLastname());
obj.put("phonenumber", customer.getPhonenumber());
obj.put("addressid", customer.getAdressID());
obj.put("password", customer.getPassword());
String urlJsonObj = URL;
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
urlJsonObj, obj,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
System.out.println(response);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Error: " + error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(jsonObjReq);
}
#Override
public int count() {
String countURL = URL + "/count";
JsonObjectRequest jsonObjReq = new JsonObjectRequest
(Request.Method.GET, countURL, null, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
// Parsing json object response
// response will be a json object
count = response.getInt("count");
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d( "Error: " + error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(jsonObjReq);
return count;
The AppController network queue
public class AppController extends Application {
public static final String TAG = AppController.class
.getSimpleName();
private RequestQueue mRequestQueue;
private static AppController mInstance;
#Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance() {
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
// set the default tag if tag is empty
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
What's Happening?
This is happening due to incorrect thread usage. count() function performs the network request in the background thread, so it won't return the count immediately when we call it from save() function.
Solution
Wait for the response from count API and then perform a save operation. Replace the above implementation with the following
#Override
public void save(Customer customer) throws JSONException {
count();
}
private void performSave(Customer customer, int count) throws JSONException {
int zw = count; // Finally received the count
JSONObject obj = new JSONObject();
obj.put("customernumber", count + 1);
obj.put("name", customer.getName());
obj.put("lastname", customer.getLastname());
obj.put("phonenumber", customer.getPhonenumber());
obj.put("addressid", customer.getAdressID());
obj.put("password", customer.getPassword());
String urlJsonObj = URL;
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
urlJsonObj, obj,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
System.out.println(response);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Error: " + error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(jsonObjReq);
}
#Override
public int count(Customer customer) {
String countURL = URL + "/count";
JsonObjectRequest jsonObjReq = new JsonObjectRequest
(Request.Method.GET, countURL, null, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
// Parsing json object response
// response will be a json object
count = response.getInt("count");
performSave(customer, count);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d( "Error: " + error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(jsonObjReq);
return 0; // Remove this return type as we will not use it anymore
}
I have written a small program using JsonObjectRequest to get the data from an API, but I've got the result but I can't use it outside the function. Can anyone help me about it? I've got stuck here for 5 days already. When I want to use response data outside of this, it always show the token is null.
Here's my code.
RequestQueue requestQueue1=Volley.newRequestQueue(this);
JsonObjectRequest objectRequest1=new JsonObjectRequest(
Request.Method.GET,
urlToken,
null,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
parseJson(response);
try {
token=response;
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}
);
requestQueue1.add(objectRequest1);
Using interface call back could be a solution: Code looks like :
interface TokenCallback {
void onTokenReceived(String token);
void onDataReceived(String responseData);
}
private void makeApiCall(String url,String token,Boolean isGetRequest,TokenCallback tokenCallback){
RequestQueue requestQueue1=Volley.newRequestQueue(this);
// put if else to adjust GET or POST request
if (isGetRequest){
// prepare Get request
}else {
// Prepare post request
}
JsonObjectRequest objectRequest1=new JsonObjectRequest(
Request.Method.GET,
url,
token,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
parseJson(response);
try {
// Parse token here
if (response.has("token")){
tokenCallback.onTokenReceived(token);
}else {
tokenCallback.onDataReceived(response.toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}
);
requestQueue1.add(objectRequest1);
}
Call above method where you are starting API call like below:
makeApiCall("https://your.api.url",null,true,new TokenCallback() {
#Override
public void onTokenReceived(String token) {
if(!token.isEmpty()){
// use token
makeApiCall("https://your.api.url",token,false,new TokenCallback() {
#Override
public void onTokenReceived(String token) { }
#Override
public void onDataReceived(String responseData) {
// Parse your json response data here......
}
});
}
}
#Override
public void onDataReceived(String responseData) {
}
});
I was looking for an easy way to make an HTTP post in Android with body, my api call should be like :
https:url/api/message?token=myToken&channel=Pew&text=someText&username=User
What I did is this, I created this class
Public class ApiCalls {
private static PostCommentResponseListener mPostCommentResponse;
private static Context mContext;
public ApiCalls(){
}
public static void postNewComment(Context context, final String message){
mContext = context;
String apiUrl = context.getResources().getString(R.string.api_url);
mPostCommentResponse.requestStarted();
RequestQueue queue = Volley.newRequestQueue(context);
StringRequest sr = new StringRequest(Request.Method.POST,apiUrl, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
mPostCommentResponse.requestCompleted();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
mPostCommentResponse.requestEndedWithError(error);
}
}){
#Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put("token",mContext.getResources().getString(R.string.access_token));
params.put("channel","pew");
params.put("text", message);
params.put("username","User");
return params;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
return params;
}
};
queue.add(sr);
}
public interface PostCommentResponseListener {
public void requestStarted();
public void requestCompleted();
public void requestEndedWithError(VolleyError error);
}
}
But it doesn't work, it only shows app has stopped.
Is good to use Volley? Or you recommend to me to use other way? I used to use HttpClient but it's deprecated now...
What I'm missing?
Log error
java.lang.NullPointerException: Attempt to invoke interface method 'void com.package.ApiCalls$PostCommentResponseListener.requestStarted()' on a null object reference
You can send json body using volly as below two ways.
1. Using JsonObjectRequest
Map<String,String> params = new HashMap<String, String>();
params.put("token",mContext.getResources().getString(R.string.access_token));
params.put("channel","pew");
params.put("text", message);
params.put("username","User");
JsonObjectRequest request_json = new JsonObjectRequest(URL, new JSONObject(params),
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
//Process success response
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
// handle error
}
});
// add the request object to the queue to be executed
queue.add(request_json);
2. Using JSON directly in request body
JSONObject jsonBody = new JSONObject();
jsonBody.put("token",mContext.getResources().getString(R.string.access_token));
jsonBody.put("channel","pew");
jsonBody.put("text", message);
jsonBody.put("username","User");
final String mRequestBody = jsonBody.toString();
StringRequest sr = new StringRequest(Request.Method.POST,apiUrl, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
// Process success response
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
// handle error
}
}){
#Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
#Override
public byte[] getBody() throws AuthFailureError {
try {
return mRequestBody.getBytes("utf-8");
} catch (Exception e) {
return null;
}
}
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String responseString = "";
if (response != null) {
responseString = String.valueOf(response.statusCode);
}
return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
}
};
// add the request object to the queue to be executed
queue.add((sr);
Initialise your mPostCommentResponse like this:
public ApiCalls(){
mPostCommmentResponse = (PostCommentResponseListener)mContext;
}
it will do you work and rest is fine. Thanks.
EDITED:
In Another Activity from where you want to call "ApiCall" class, do code like that:
new ApiCalls().postNewComment(AnotherActivity.this,"Your Messsage here");
and in method "postNewComment" do like this:
mContext = context;
mPostCommmentResponse = (PostCommentResponseListener)mContext;
Is it ok and understable??
I have got a JSON response from an API that I have converted to a string and trying to compare it for true or false value,
On the log cat I can see the result:
{
"message": "success",
"status": "Auth_Successful",
"response": "Authentication successful"
}
I am trying fit it into an if statement like below
I have tried most of the comparison methods(==, .equals(), .compareTo()) but not getting any result
Can anyone let me know what is the correct way to approach it as I am still new to Java and Android. I have seen a lot of similar posts but unable to figure out.
Thank you very much for your time and assistance in this matter.
package com.example.shiben.fabapp;
public class MainActivity extends AppCompatActivity {
private Request request;
private static final String Tag = MainActivity.class.getName();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button LoginButton = (Button) findViewById(R.id.loginButton);
EditText userName = (EditText) findViewById(R.id.userName);
EditText userPassword = (EditText) findViewById(R.id.userPassword);
final TextView displayTest = (TextView) findViewById(R.id.displayTest);
LoginButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "username=xxxxxxxxx&password=xxxxxxxxx");
Request request = new Request.Builder()
.url("http://9.xxx.xxx.xxx/test/xxxxx_api.aspx")
.post(body)
.addHeader("cache-control", "no-cache")
.addHeader("content-type", "application/json")
.build();
//execute the request
client.newCall(request).enqueue(new Callback() {
#Override
public void onFailure(Call call, IOException e) {
Log.i(Tag, e.getMessage());
}
#Override
public void onResponse(Call call, Response response) throws IOException {
Log.i(Tag, response.body().string());
String result = response.body().toString();
//if (result==("{\"message\":\"success\",\"status\":\"Auth_Successful\",\"response\":\"Authentication successful\"}")){
if (result.compareTo("{\"message\":\"success\",\"status\":\"Auth_Successful\",\"response\":\"Authentication successful\"}")==0) {
//if (result.equals("{\"message\":\"success\",\"status\":\"Auth_Successful\",\"response\":\"Authentication successful\"}")) {
TastyToast.makeText(MainActivity.this, "String Comparison Success", TastyToast.LENGTH_LONG, TastyToast.SUCCESS);
}
}
});
}
});
}
}
You should parse the JSON string and compare the message.
if (message.equals("success"))
If you don't like to parse, you may try this one (Bad practice):
if(response.contains("success"))
String result = response.body().toString(); doesn't work. Please use string() method instead of toString()
#Override
public void onResponse(Response response) throws IOException {
if (response.isSuccessful()) {
doSomething(response.body().string());
}
}
private void doSomething(String response) {
}
Try this in your code .
String result = response.body().toString();
if(TextUtils.isEmpty(result)){
Toast.makeText(this, "result is null", Toast.LENGTH_SHORT).show();
return;
}
try {
JSONObject jsonObject = new JSONObject(result);
String message = jsonObject.optString("message");
String status = jsonObject.optString("status");
String response = jsonObject.optString("response");
if (TextUtils.equals("success", message)) {
TastyToast.makeText(MainActivity.this, "String Comparison Success", TastyToast.LENGTH_LONG, TastyToast.SUCCESS);
}
} catch (JSONException e) {
e.printStackTrace();
}
The problem is related with OkHttp
This is because when you called the following:
Log.i(Tag, response.body().string());
String result = response.body().toString();
String result will be empty because you've already called response.body() in Log. When you called it, it will be emptied.
So, you need to save it to the result before calling it from the log. Something like this:
String result = response.body().toString();
Log.i(Tag, result);
Here from the documentation:
The response body can be consumed only once.
This class may be used to stream very large responses. For example, it
is possible to use this class to read a response that is larger than
the entire memory allocated to the current process. It can even stream
a response larger than the total storage on the current device, which
is a common requirement for video streaming applications.
Because this class does not buffer the full response in memory, the
application may not re-read the bytes of the response. Use this one
shot to read the entire response into memory with bytes() or string().
Or stream the response with either source(), byteStream(), or
charStream().
I used volley instead of okhttp and got it sorted ,
Below is the code
public class MainActivity extends AppCompatActivity {
private static final String TAG = MainActivity.class.getName();
private Button btnSendRequest;
private RequestQueue mRequestQueue;
//creating a string request
private StringRequest stringRequest;
private String url = "http://9.xxx.xxx.xxx/test/xxxxxxx.aspx";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSendRequest = (Button) findViewById(R.id.loginBtn);
btnSendRequest.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//on click of the button send request and print the response
//initializing request queue and string request in sendRequestAndPrintResponse
sendRequestAndPrintResponse();
}
});
}
private void sendRequestAndPrintResponse() {
mRequestQueue = Volley.newRequestQueue(this);
stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.i(TAG, "Success" + response.toString());
String result = response.toString();
TextView displayText = (TextView) findViewById(R.id.displayText);
displayText.setText(result);
if (result.equalsIgnoreCase("{\"message\":\"success\",\"status\":\"Auth_Successful\",\"response\":\"Authentication successful\"}")){
Toast.makeText(getApplicationContext(), "comparison successful", Toast.LENGTH_LONG).show();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.i(TAG, error.toString());
}
}){
#Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<String, String>();
params.put("username", "someone#example.com");
params.put("password", "myPassword");
return params;
}
};
mRequestQueue.add(stringRequest);
}
}
If anyone could let me know what went wrong with okhttp, it would be very helpful for future reference.
I'm trying to use Volley as a DBA layer to call a webservice that hadles JSON objects. Because this layer is below the activity and another service layer, it doesn't seem to be working properly. I'll try to explain my setup:
MainActivity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ProductService productService = new ProductService();
productService.getProduct();
}
ProductService.java:
public void getProduct() {
JsonObjectRequest req = new JsonObjectRequest("http://echo.jsontest.com/name/Milk/price/1.23/", null, createMyReqSuccessListener(), createMyReqErrorListener());
ApplicationController.getInstance().addToRequestQueue(req);
}
private Response.Listener<JSONObject> createMyReqSuccessListener() {
return new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
Log.v("response", response.toString());
}
};
}
private Response.ErrorListener createMyReqErrorListener() {
return new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
return;
}
};
}
I hope that is clear enough.
In the end, I would like to use the ProductService::getProduct() from an activity and the the actual JSON response from the webservice in a variable which I can later use.
However, at the moment, the line
Log.v("response", response.toString());
doesn't even execute. What am I doing wrong?
What I would try is this:
Declare getProduct as
public void getProduct(Response.Listener<JSONObject> listener,
Response.ErrorListener errlsn) {
JsonObjectRequest req = new JsonObjectRequest("http://echo.jsontest.com/name/Milk/price/1.23/",null, listener, errlsn);
ApplicationController.getInstance().addToRequestQueue(req);
}
And than call in your activity like this:
productService.getProduct(
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
variableFromActivity = response;
//Or call a function from the activity, or whatever...
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
//Show error or whatever...
}
});
Create an abstract class AppActivity
import androidx.appcompat.app.AppCompatActivity;
public abstract class AppActivity extends AppCompatActivity
{
abstract void callback(String data);
}
Extend all your Activities using AppActivity
public class MainActivity extends AppActivity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "Your URL";
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put("Title", "Android Volley Demo");
jsonBody.put("Author", "BNK");
}
catch (JSONException e) {
System.out.println(e);
}
final String requestBody = jsonBody.toString();
Messenger messenger = new Messenger(MainActivity.this);
messenger.sendMessage(this, url, requestBody);
}
public void callback(String data)
{
System.out.println(data);
}
}
Create Messenger class as below:
public class Messenger
{
private AppActivity myActivity;
public Messenger(AppActivity activity)
{
myActivity = activity;
}
public void sendMessage(Context context, String url, final String requestBody)
{
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(context);
// Request a string response from the provided URL.
StringRequest stringRequest =
new StringRequest(
Request.Method.POST,
url,
null,
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
System.out.println(error);
}
}
) {
#Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
#Override
public byte[] getBody() throws AuthFailureError {
try {
return requestBody == null ? null : requestBody.getBytes("utf-8");
}
catch (UnsupportedEncodingException uee) {
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", requestBody, "utf-8");
return null;
}
}
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response)
{
myActivity.callback(new String(response.data));
String responseString = "";
if (response != null) {
responseString = String.valueOf(response.statusCode);
// can get more details such as response.headers
}
return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
}
};
queue.add(stringRequest);
}
}
Hope it helps.