title: HttpPost retrieve on server, using volley library and overriding getParams doesn't retrieve
body: <p>According to <a href="http://www.androidhive.info/2014/05/android-working-with-volley-library-1/" rel="nofollow">http://www.androidhive.info/2014/05/android-working-with-volley-library-1/</a> , part 6, I want to send user and password, and retrieve status of login; as same as description of part 6!</p>
  
  <p>I'm using volley library, and <strong>override getParams</strong> function to set Keys Values. And sent as <strong>POST</strong> to php page.</p>
  
  <p>This is snippet code via volley library:</p>
  
  <pre><code>url = "http://www.myurl.com/app/page.php";
  TAG = "tagToCancelReq";
  JsonObjectRequest postRequest = new JsonObjectRequest (Request.Method.POST, url, 
      new Response.Listener&lt;String&gt;() 
      {
          @Override
          public void onResponse(JsonObject response) {
              // response
              Log.d("Response", response.toString());
          }
      }, 
      new Response.ErrorListener() 
      {
           @Override
           public void onErrorResponse(VolleyError error) {
               // error
              Log.d("Error.Response", response);
         }
      }
  ) {     
      @Override
      protected Map&lt;String, String&gt; getParams() 
      {  
              Map&lt;String, String&gt;  params = new HashMap&lt;String, String&gt;();  
              params.put("user", "client1");  
              params.put("pass", "123");
  
              return params;  
      }
  };
  
  queue.addToRequest(postRequest,TAG);
  </code></pre>
  
  <p>This is php code:</p>
  
  <pre><code>**&lt;?php
  /* Encode array to JSON string */
  function encodearray($posts) {
      header('Content-type: application/json');
      echo json_encode(array('posts'=&gt;$posts));
  }
  $response = array();
  if (isset($_POST['p']) &amp;&amp; isset($_POST['v'])) {
      $response["success"] = 1;
      foreach ($_POST as $key =&gt; $value)
      {
          $response[$key] = $value;
      }
  
      $con = mysql_connect("localhost", "username", "password") or die(mysql_error());
      $db = mysql_select_db("db") or die(mysql_error());
      $strsql = "INSERT INTO `users` (";
      $strsql .= implode(",", array_keys($response));
      $strsql .= ") VALUES ('";
      $strsql .= implode("','", array_values($response));
      $strsql .= "')";
      mysql_query($strsql) or die($db-&gt;error());
  
      /* encode the JSON post from the array */
      encodearray($response);
  } else {
      // required field is missing
      $response["success"] = 0;
      $response["message"] = "Required field(s) is missing";
  
      // echoing JSON response
      echo json_encode($response);
  }
  ?&gt;**
  </code></pre>
  
  <p>In this way, server response <strong>success = 0</strong>.</p>
  
  <p><strong>But</strong> when using <strong>httpPost and Asynctask</strong> like this, server retrieve request and response correctly. Code is:</p>
  
  <pre><code>HttpClient httpclient = new DefaultHttpClient();
  HttpPost httppost = new HttpPost("http://www.myurl.com/app/page.php");
  // Add your data   
  List &lt; NameValuePair &gt; nameValuePairs = new ArrayList &lt; NameValuePair &gt; (5);
  nameValuePairs.add(new BasicNameValuePair("user", "client1"));
  nameValuePairs.add(new BasicNameValuePair("pass", "123"));
  
  
  try {
      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
      Log.d("myapp", "works till here. 2");
          try {
          HttpResponse response = httpclient.execute(httppost);
          Log.d("myapp", "response " + response.getEntity());
          } catch (ClientProtocolException e) {
              e.printStackTrace();
  } catch (IOException e) {
  e.printStackTrace();
  }
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  </code></pre>
  
  <p>} </p>
  
  <p>What is wrong with first way?</p>
  
  <p><strong>Even</strong> when i use local web server(wamp server), and change URL to</p>
  
  <pre><code>http://10.0.2.2:80/adnroid_server/get_All.php";
  </code></pre>
  
  <p>and run app on emulator, in first way (volley), server doesn't response (no error too), and in second way(httPost) every thing is correct and response retrieved.</p>