Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. new AsyncTask<Void, Void, String>() {
  2. @Override
  3. protected String doInBackground(Void... params) {
  4. String msg = "";
  5.  
  6. DefaultHttpClient httpclient = new DefaultHttpClient();
  7.  
  8. HttpPost httpPost = new HttpPost("http://127.0.0.1:52273/get");
  9. httpPost.setHeader("Content-type", "application/json");
  10. try {
  11. HttpResponse httpresponse = httpclient.execute(httpPost);
  12. String result = EntityUtils.toString(httpresponse.getEntity());
  13. } catch (ClientProtocolException e) {
  14. Log.v("ClientProtocolException", "ClientProtocolException");
  15.  
  16. e.printStackTrace();
  17. // TODO Auto-generated catch block
  18. } catch (IOException e) {
  19. Log.v("IOException", "IOException");
  20.  
  21. // TODO Auto-generated catch block
  22. e.printStackTrace();
  23. }
  24.  
  25. return msg;
  26. }
  27.  
  28. app.post('/get',function(request,response){
  29. response.writeHead(200, { 'Content-Type': 'application/json' });
  30. response.json({success:1});
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement