I want to build an android application to send an image data over a server. To start with, I wanted to send the text data from my app to localhost on my machine. I am using a WAMP server.
I have written this code on eclipse and also created mypage.php on C:/wamp/www/ folder
package com.example.httpexample;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://localhost/mypage.php");
        try {
             List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
             nameValuePairs.add(new BasicNameValuePair("fname", "vinod"));
             nameValuePairs.add(new BasicNameValuePair("fphone", "1234567890"));
             nameValuePairs.add(new BasicNameValuePair("femail", "abc@gmail.com"));
             nameValuePairs.add(new BasicNameValuePair("fcomment", "Help"));
             httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
             httpclient.execute(httppost);
         } catch (ClientProtocolException e) {
             // TODO Auto-generated catch block
         } catch (IOException e) {
             // TODO Auto-generated catch block
         }
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}
But when I run the emulator I can't see that the data is sent from the emulator to mytest.php file on the localhost.
I am new in this domain and probably not doing some things right. Please suggest a way out. Ask me for more details if you want to. Also I would like to tell that my institute uses a proxy server( but since I am connecting to my machine shouldnt be a problem).
 
     
    