android中的主机名可能不是null错误

时间:2013-02-27 20:10:21

标签: java android http-post

我在Android应用中收到错误“主机名可能不为空错误”。

这是我的代码:

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost("http://sub_domain.domain.com/service/api");
httpost.setHeader("Accept", "application/json");
httpost.setHeader("Content-type", "application/json");
ResponseHandler responseHandler = new BasicResponseHandler();
    try {
        httpclient.execute(httpost, responseHandler);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

我使用子域名,所以我不能将'www'放在我的网址中,因为它是另一个子域名。 我的清单文件中有Internet权限。

有什么建议吗?谢谢!

编辑:使用GET方法无法访问此网址。

我的子域名中没有'_',没关系。

2 个答案:

答案 0 :(得分:3)

看这个链接。 Apache不支持下划线

https://issues.apache.org/jira/browse/HTTPCLIENT-911

答案 1 :(得分:0)

在我的应用程序运行过程中,当我的网络连接中断时,我遇到了类似的错误。我使用了异步任务当Async任务找不到链接时,/它给出类似的Window Leak结果。

相关问题