title: Android HTTP post not working
body: <p>It's my first time making http post or get. Am trying my best to get it working here is my code and url: <a href="http://ownvehicle.askmid.com/" rel="nofollow">http://ownvehicle.askmid.com/</a></p>
  
  <p>Not sure why I am not getting response also there is a captcha image there not sure how to get that to imageview and send the data.</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.UnsupportedEncodingException;
  import java.net.URL;
  import java.net.URLConnection;
  import java.net.URLEncoder;
  
  public class MainActivity2Activity extends Activity{
  
      TextView content;
      EditText fname, email, login, pass;
      String Name, Email, Login, Pass;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main_activity2);
  
          content    =   (TextView)findViewById( R.id.content );
          fname      =   (EditText)findViewById(R.id.name);
         // email      =   (EditText)findViewById(R.id.email);
         // login      =    (EditText)findViewById(R.id.loginname);
         // pass       =   (EditText)findViewById(R.id.password);
  
  
          Button saveme=(Button)findViewById(R.id.save);
  
          saveme.setOnClickListener(new Button.OnClickListener(){
  
              public void onClick(View v)
              {
                  try{
  
                      // CALL GetText method to make post method call
                      GetText();
                  }
                  catch(Exception ex)
                  {
                      content.setText(" url exeption! " );
                  }
              }
          });
      }
  
      // Create GetText Metod
      public  void  GetText()  throws UnsupportedEncodingException
      {
          // Get user defined values
          Name = fname.getText().toString();
         // Email   = email.getText().toString();
         // Login   = login.getText().toString();
          //Pass   = pass.getText().toString();
  
          // Create data variable for sent values to server
  
          String data = URLEncoder.encode("regno", "UTF-8")
                  + "=" + URLEncoder.encode(Name, "UTF-8");
  
        //  data += "&amp;" + URLEncoder.encode("email", "UTF-8") + "="
             //     + URLEncoder.encode(Email, "UTF-8");
  
      //    data += "&amp;" + URLEncoder.encode("user", "UTF-8")
             //     + "=" + URLEncoder.encode(Login, "UTF-8");
  
         // data += "&amp;" + URLEncoder.encode("pass", "UTF-8")
                 // + "=" + URLEncoder.encode(Pass, "UTF-8");
  
          String text = "";
          BufferedReader reader=null;
  
          // Send data
          try
          {
  
              // Defined URL  where to send data
              URL url = new URL("http://ownvehicle.askmid.com/");
  
              // Send POST data request
  
              URLConnection conn = url.openConnection();
              conn.setDoOutput(true);
              OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
              wr.write( data );
              wr.flush();
  
              // Get the server response
  
              reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
              StringBuilder sb = new StringBuilder();
              String line = null;
  
              // Read Server Response
              while((line = reader.readLine()) != null)
              {
                  // Append server response in string
                  sb.append(line + "\n");
              }
  
  
              text = sb.toString();
          }
          catch(Exception ex)
          {
  
          }
          finally
          {
              try
              {
  
                  reader.close();
              }
  
              catch(Exception ex) {}
          }
  
          // Show response on activity
          content.setText( text  );
  
      }
  
  }
  </code></pre>
  
  <p>here is layout code</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Enter Something Below:"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true" /&gt;
  
      &lt;EditText
          android:id="@+id/name"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="77dp"
          android:ems="10"
          android:hint=""
          android:layout_below="@+id/textView1"
          android:layout_alignLeft="@+id/textView1"
          android:layout_alignStart="@+id/textView1"&gt;
  
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;Button
          android:id="@+id/save"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Submit"
          android:layout_centerVertical="true"
          android:layout_alignLeft="@+id/content"
          android:layout_alignStart="@+id/content" /&gt;
  
      &lt;EditText
          android:id="@+id/editText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:ems="10"
          android:hint=""
          android:layout_below="@+id/name"
          android:layout_alignLeft="@+id/name"
          android:layout_alignStart="@+id/name" /&gt;
  
      &lt;EditText
          android:id="@+id/editText2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:ems="10"
          android:hint=""
          android:layout_below="@+id/editText"
          android:layout_alignLeft="@+id/editText"
          android:layout_alignStart="@+id/editText" /&gt;
  
      &lt;EditText
          android:id="@+id/content"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:ems="10"
          android:hint=""
          android:layout_below="@+id/save"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          android:layout_alignParentBottom="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>