简体   繁体   中英

Retrieve data from Android HTTP Post

I have been looking at several other posts and what I'm trying to do is that retrieve the object over request with Android which is set.

I'm using google gcm application.

My Android the code is :

DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler <String> res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost("http://192.168.1.111:8080/abc/d");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();  
nameValuePairs.add(new BasicNameValuePair("My_Value", "My_Value_entered"));  
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));  
String response=hc.execute(postMethod,res);

I want to fetch the the value My_value in my Application(in the servlet end).

Edit: If any change or modification is needed in my android code to get the object value from Android Post,feel free to reply.

Any idea.....

You can try jsoup which is much easier to use. You can check it at jsoup.org

edit:

like this:

Document document = Jsoup.connect("http://www......com/....php")
                .data("user","user","password","12345","email","info@tutorialswindow.com")
                .method(Method.POST)
                .execute()
                .parse();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM