Android/Apache HTTPGET 将不起作用,但在浏览器中它可以

Android/Apache HTTPGET Will not work, but in browser it does

我在 tomcat 上有一个简单的 servlet 运行。它实现了一个简单的 doGet() 并在我从网络浏览器调用它时工作,例如:

http://192.168.1.140:8080/Application/doTask?id=0&param=something

但是,我试图从 android 应用程序中调用它,除了挂起之外,我什么也没得到。我在 AsyncTask 中 运行 它所以它不是真正的挂起,但我在 "SendServerThread"

中有它
public SendServerThread(String state, int isHalfway) {
    mState = state;
    mIsHalfWay = mIsHalfWay;

    mRestClient = new RestClient();
}

@Override
protected String doInBackground(String... params) {
    HttpClient httpClient = new DefaultHttpClient();
    String response = "";
    try {
        URI urlString = new URI(PI_ADDRESS + "/Application/API?id=0&setState=" + mState + "&percentage=" + mIsHalfWay);
        HttpGet httpGetRequest = new HttpGet();
        httpGetRequest.setURI(urlString);

        HttpResponse httpResponse = httpClient.execute(httpGetRequest);

        String line = "";
        BufferedReader br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
        while ((line = br.readLine()) != null) {
            response+=line;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        httpClient.getConnectionManager().shutdown();
    }

    return response;
}

我验证了 URL 它的调用是正确的,但我什么也没得到。没有反应。我有上网权限。

我这样称呼它来自 UI:

            new SendServerThread(state, isHalfWay)
            {
                @Override public void onPostExecute(String result)
                {
                    unlockUI();
                }
            }.execute("");

它通过 HttpGet,但线程从未得到响应。如果我在 phone 上进入网络浏览器,我会得到结果。但是从应用程序中我什么也没得到 - 线程挂起。

非常感谢任何想法,无法弄清楚我做错了什么

我打开了飞行模式,然后打开了 WiFi,所以所有移动数据都被禁用了,然后就可以了:(

如果您使用模拟器进行测试,本地主机的 IP 地址为 10.0.2.2