title: how to get http status code in volley library when response in success.?
body: <p>I know its a repetitive question, but still. Can any one provide me a solution or workaround to get status code returned with the response when we make a network rest api call?</p>
  
  <p><a href="https://stackoverflow.com/questions/25271686/how-to-get-status-code-in-successful-response-volley-android">Here</a> provided a work around. But I didn't understood. Can any one explain me in a better way the solution.?</p>
  
  <p>The rest api returns many success status code like 201,204 and many server errors. </p>
  
  <p>I want to check status code before proceeding and have to make decision accordingly.</p>
  
  <p>This is my existing code.</p>
  
  <p>on a button click</p>
  
  <pre><code>RequestQueue queue;
  queue = Volley.newRequestQueue(this);
  final String[] token = new String[1];
  String status;
  String url = "http://myapiurl";
  JsonObjectRequest postRequest = new JsonObjectRequest(Request.Method.GET, url,
      new Response.Listener&lt;JSONObject&gt;() {
          @Override
          public void onResponse(JSONObject response) {
              try {
                  // want to get status code here
                  token[0] = response.getString("message");
                  Toast.makeText(getApplicationContext(),token[0],Toast.LENGTH_SHORT).show();
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      },
      new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              // error
              Log.d("Error.Response", String.valueOf(error));
          }
      }
  );
  queue.add(postRequest);
  </code></pre>