Android 之 Http-get
public void get() {
String url = httpUrl + "?text1=" +
text1.getText().toString()
+ "&text2=" +
text2.getText().toString();
// 创建HttpGet对象
HttpGet request = new
HttpGet(url);
// 创建HttpClient对象
HttpClient client = new
DefaultHttpClient();
HttpResponse httpResponse = null;
try
{
httpResponse = client.execute(request);
if
(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
text3.setText(EntityUtils.toString(httpResponse.getEntity(),
"utf-8"));
}
}
catch (ClientProtocolException e) {
e.printStackTrace();
} catch
(IOException e) {
e.printStackTrace();
}
}
想要获得成功,首先要自己相信自己,再者要赢得周围朋友的信任!
浙公网安备 33010602011771号