Android 2.2 (level 8) httpclient.execute serial timeout

I try to get a response from a sedative service, but I get a timeout. I can connect to the browser on my emulator, since I configured the access point on the emulated device to go through the proxy (at work). The network seems beautiful. I added:

<uses-permission android:name="android.permission.INTERNET" /> 

to the AndroidManifest.xml file.

The code is as follows:

public String getInputStreamFromUrl(String url) {
    String content = null;
    InputStream stream = null;
    try {
        HttpGet httpGet = new HttpGet(url);
        HttpClient httpclient = new DefaultHttpClient();
        // Execute HTTP Get Request
        HttpResponse response = httpclient.execute(httpGet);
        stream = response.getEntity().getContent();
        BufferedReader rd = new BufferedReader(new InputStreamReader(stream), 4096);
        String line;
        StringBuilder sb =  new StringBuilder();
        while ((line = rd.readLine()) != null) {
                sb.append(line);
        }
        rd.close();
        content = sb.toString();
            } catch (Exception e) {
        content = e.getMessage();
    }
    return content;

I know that I should return a stream, but in order to just display some string values ​​in TextView widgets, that’s enough, so I just use the string for experimentation. It hangs .execute constantly, no matter what URL is passed. I also went through a valid IP address but did nothing.

I appreciate your help in advance.

+3
1

. .

System.setProperty("http.proxyHost", <your proxy host name>);
System.setProperty("http.proxyPort", <your proxy port>);
0

All Articles