How can I perform GET method in android?
I want to get this data ---->"#1$Egypt$مصر@" from this link --> "http://184.173.7.132/mobile.aspx?action=4"
I used this code but the response is NULL
public HttpResponse doGet(String url) throws Exception {
HttpResponse response = null;
try {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
response = httpclient.execute(httpget);
}
开发者_开发知识库 catch (IOException e) {
e.printStackTrace();
}
return response;
}
Use this code it is worked for your url. add internet permission in manifest
String page;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://184.173.7.132/mobile.aspx?action=4");
// httpGet.addHeader("Content-type","application/json");
ResponseHandler<String> resHandler = new BasicResponseHandler();
try
{
page = httpClient.execute(httpGet, resHandler);
}
catch (ClientProtocolException e)
{
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
}
Log.e("response",page);
精彩评论