1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| public String envoyer()
{
URLConnection url;
HttpClient client = new DefaultHttpClient();
String aurl= "http://localhost:4848/WebTracking/AndroidS";
HttpGet get= new HttpGet(aurl);
HttpPost post=new HttpPost(aurl);
OutputStream os = null;
InputStream in = null;
HttpResponse reponse;
String result=null;
try {
Log.i("infor", "==========================A=====================");
InetAddress id= InetAddress.getLocalHost();
Log.i("infor", "========================After InetAddress==================="+id);
} catch (UnknownHostException e1) {
Log.i("infor", "==========================A====================="+e1.toString());
e1.printStackTrace();
}
try
{
Log.i("infor", "==========================A=====================");
reponse= client.execute(post);
Log.i("infor", "==========================B=====================");
HttpEntity entite=reponse.getEntity();
Log.i("infor", "==========================C=====================");
if( entite!=null)
{
Log.i("infor", "==========================D=====================");
in=entite.getContent();
Log.i("infor", "==========================E=====================");
result= convert(in);
Log.i("infor", "==========================F=====================");
tv.setText(result);
Log.i("infor", "==========================G=====================");
}
}
catch(Exception e)
{
Log.i("infor", "=============ccc=============1====================="+e.toString());
}
String response = null; |
Partager