Android的HTTP连接被拒绝被拒、Android、HTTP

2023-09-05 01:25:47 作者:╰☆緈諨ぷ棒棒糖゛

我想从Android设备访问通过WiFi我可以访问我的笔记本电脑无论是在浏览器中的本地Web服务器,或使用卷曲。我还可以访问服务器上的Andr​​oid设备浏览器。

在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);
  }
}
 

解决方案

问题解决了。问题是损坏的清单文件。我删除权限线和重新输入他们,现在的问题已经一去不复返了。

手机连wifi就提示连接被拒绝 是自己家的电信网 密码也是我自己设置的 怎么会上不去呢 了解的前辈

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