I can't send post request to the server from my Android app. I have found some examples about how to send POST but I have some error with my code and here is the 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() > 0 && givenEmail2.length() > 0) { HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(post_url); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 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() + "&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; } } so can somebody help me with it? i am just started Android development and don't know many tricks or something difficult...