title: Volley getting an error response
body: <p>I am sending some post data using volley. Here is my code . It's a snippet from background service. Let me know if you want other files also. I've added the internet permission. </p>
  
  <pre><code>    public void onLocationChanged(final Location location) {
          mCurrentLocation = location;
          pref.setLocation(location);
  
          String url = getResources().getString(R.string.hostname); // it's a normal http 
  
          StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                  new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
                          Toast.makeText(getApplicationContext(), "Location sent", Toast.LENGTH_SHORT).show();
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
  
                          String errorMessage = "Err - data:"+error.getMessage();
                          Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_SHORT).show();
                  }
                })
                      {
                          @Override
                          protected Map&lt;String,String&gt; getParams(){
                              Map&lt;String,String&gt; params = new HashMap&lt;String, String&gt;();
                              params.put(KEY_USERID,pref.getUserId());
                              params.put(KEY_LAT,String.valueOf(location.getLatitude()));
                              params.put(KEY_LNG,String.valueOf(location.getLongitude()));
                              return params;
                          }
  
                      };
          queue.add(stringRequest);
      }
  </code></pre>