Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void postData() {
- // Create a new HttpClient and Post Header
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost("http://somewhere.net/default.php");
- try {
- // Add your data
- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
- nameValuePairs.add(new BasicNameValuePair("thename", "Steve"));
- nameValuePairs.add(new BasicNameValuePair("theage", "24"));
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- // Execute HTTP Post Request
- //HttpResponse response = httpclient.execute(httppost);
- // Execute HTTP Post Request
- ResponseHandler<String> responseHandler=new BasicResponseHandler();
- String responseBody = httpclient.execute(httppost, responseHandler);
- //Just display the response back
- displayToastMessage(responseBody);
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- } catch (IOException e) {
- // TODO Auto-generated catch block
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement