\"http://184.173.7.132/mobile.aspx?action=4\"" />
开发者

How can I perform GET method in android?

开发者 https://www.devze.com 2023-04-09 05:22 出处:网络
I want to get this data ---->\"#1$Egypt$مصر@\" from this link --> \"http://184.173.7.132/mobile.aspx?action=4\"

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消