title: Android, how to send POST request
body: <p>I can't send post request to the server from my Android app.
  I have found some examples about how to send <strong>POST</strong> but I have some error with my code and here is the code:</p>
  
  <pre><code>public class MainActivity extends Activity 
  {
  private WebView wv; //Internet
  private EditText email1; //Edit's
  private EditText email2; //Edit's
  private Button btn_get_access; //Get Access
  private String post_url = "http://rasnacis.lv/vova.php";
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {       
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      wv = (WebView) findViewById(R.id.webView1);
      email1 = (EditText) findViewById(R.id.txt_email_1);
      email2 = (EditText) findViewById(R.id.txt_email_2);
      btn_get_access = (Button) findViewById(R.id.btn_get_access);
  
      WebSettings webSettings = wv.getSettings();
      webSettings.setSaveFormData(true);
  
      //BUTTON
      OnClickListener ocl_btn_get_access = new OnClickListener()
      {
  
          public void onClick(View v) 
          {
  
              String givenEmail1 = email1.getEditableText().toString();
              String givenEmail2 = email2.getEditableText().toString();
  
              //SENDING POST
              if (givenEmail1.length() &gt; 0 &amp;&amp; givenEmail2.length() &gt; 0)
              {
                  HttpClient httpClient = new DefaultHttpClient();
                  HttpPost httpPost = new HttpPost(post_url);
  
                  try
                  {
                      List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                      nameValuePairs.add(new BasicNameValuePair("email1", "email2"));
                      nameValuePairs.add(new BasicNameValuePair("email1", "slgjlskjgsg"));
                      nameValuePairs.add(new BasicNameValuePair("email2", "xkjfhgkdjfhgkdjfg"));
  
                      httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                      httpClient.execute(httpPost);
                  }
                  catch (ClientProtocolException e) 
                  {
                      System.out.println("First Exception caz of HttpResponese :" + e);
                      e.printStackTrace();
                  }
                  catch (IOException e) 
                  {
                      System.out.println("Second Exception caz of HttpResponse :" + e);
                      e.printStackTrace();
                  }
              }
              else
              {
                  Toast.makeText(getBaseContext(), "All fields are required!", Toast.LENGTH_SHORT).show();
              }
  
              //sending GET
              //wv.loadUrl("http://rasnacis.lv/vova.php?email1=" + email1.getText() + "&amp;email2=" + email2.getText());
          }
      };
      btn_get_access.setOnClickListener(ocl_btn_get_access);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  
  }
  </code></pre>
  
  <p>so can somebody help me with it? i am just started Android development and don't know many tricks or something difficult...</p>