为什么android 2.1-update1挂在HttpClient.execute()而不是android 2.2?

时间:2011-03-02 11:35:23

标签: android-2.2-froyo android-2.1-eclair

我正在编写一个Android应用程序,它使用Apache Commons项目的HttpClient接口发出请求(随两个版本的android一起提供)。

以下代码清单中出现问题:

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做得很好(API级别8),但是当我在Android 2.1-update1(API级别7)上运行时,它会在client.execute(request)处“挂起”。我做错了什么?

1 个答案:

答案 0 :(得分:0)

好的,我自己想出来了。

部分问题是我必须使用模拟器中的10.0.2.2并编写了一个使用模型检测模拟器的类。字符串google_sdk之前对我来说很好。但是昨天我更新了我的SDK,显然他们把它改为sdk,所以这个类之前没有将设备检测为仿真器并使用了错误的IP地址。

状态:已解决!

相关问题