0

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;

} 
1
  • do you get the IOException maybe? - Have you added INTERNET permissions to the manifest?
    – Marqs
    Sep 28, 2011 at 13:57

1 Answer 1

2

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);
3
  • what is this line "Log.e("response",page);" do?? Sep 28, 2011 at 14:11
  • just to see response in logcat, you can use Toast instead
    – Abhi
    Sep 28, 2011 at 14:16
  • I have another problem in parsing the resulted string.... the array 'splitc' in this line of code "String[] splitC=page.split("$"));" is still have the value #1$Egypt$مصر@ after parsing .. what goes wrong with it :S Sep 28, 2011 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.