Why does android 2.1-update1 hang on HttpClient.execute() and not android 2.2?

651 Views Asked by At

I am writing an android app that makes requests using the HttpClient interface from the Apache Commons project (supplied with both versions of android).

The problem occurs in the following code listing:

try {
        URI uri = URIUtils.createURI(SCHEME, host, DEFAULT_PORT, QUERY, 
            URLEncodedUtils.format(qparams, ENCODING), EMPTY_FRAGMENT);
        HttpUriRequest request = new HttpGet(uri);
        response = client.execute(request);
    } catch (Exception e) {
        throw new CheckedSecurityException("Could not execute request", e);
    }

Android 2.2 does this just fine (API level 8) but when I run this on Android 2.1-update1 (API level 7) it "hangs" at client.execute(request). What am I doing wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

Okay, I figured this out myself.

Part of the problem was that I had to use 10.0.2.2 from the emulator and I wrote a class that detects the emulator using the model. the string google_sdk worked fine for me before. But yesterday I updated my SDK and apparently they changed it to just sdk so the class wasn't detecting the device as an emulator before and was using the wrong IP address.

Status: Solved!