Android的HTTP连接被拒绝 [英] Android HTTP Connection refused
本文介绍了Android的HTTP连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从Android设备访问通过WiFi我可以访问我的笔记本电脑无论是在浏览器中的本地Web服务器,或使用卷曲。我还可以访问服务器上的Android设备浏览器。
在code我使用访问该服务器产生一个连接被拒绝的异常。
这是在code:
公共无效getController1(){
HttpClient的HttpClient的=新DefaultHttpClient();
HTTPGET HTTPGET =新HTTPGET(http://192.168.1.169:8000);
HTT presponse响应= NULL;
的System.out.println(httpget.toString());
尝试 {
响应= httpclient.execute(HTTPGET);
txtViewStatus.setText(控制器1 - 确定+响应);
}赶上(例外五){
e.printStackTrace();
txtViewStatus.setText(控制器1 - 错误+ E);
}
}
解决方案
问题解决了。问题是损坏的清单文件。我删除权限线和重新输入他们,现在的问题已经一去不复返了。
I am trying to access from an Android device over Wifi a local web server which I can access from my laptop either on the browser, or using curl. I can also access the server on the android device browser.
The code I am using to access the server yields a "connection refused" exception.
This is the code:
public void getController1() {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://192.168.1.169:8000");
HttpResponse response = null;
System.out.println(httpget.toString());
try {
response= httpclient.execute(httpget);
txtViewStatus.setText("Controller 1 - OK"+response);
} catch(Exception e) {
e.printStackTrace();
txtViewStatus.setText("Controller 1 - Error"+e);
}
}
解决方案
Problem solved. The issue was a corrupted manifest file. I deleted the permission lines and re-typed them in and now the problem is gone
这篇关于Android的HTTP连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文