50,528
社区成员
发帖
与我相关
我的任务
分享
public void onClick(View v) {
new Thread(){
public void run(){
String uriApi="http://oem.card/publicdir/index.htm?password=0000";
HttpGet httpRequest = new HttpGet(uriApi);
try{
HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);
if(httpResponse.getStatusLine().getStatusCode() == 200)
{
String strResult = EntityUtils.toString(httpResponse.getEntity());
System.out.println("get strResult="+strResult);
}
else
{
mTextView.setText("Error Response:"+httpResponse.getStatusLine().toString());
}
}catch(ClientProtocolException e){
mTextView.setText(e.getMessage().toString());
e.printStackTrace();
} catch (IOException e) {
mTextView.setText(e.getMessage().toString());
e.printStackTrace();
}catch(Exception e){
mTextView.setText(e.getMessage().toString());
e.printStackTrace();
}
}
}.start();
}