开发者

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

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, 
           开发者_如何学Go 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?


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!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜