即使具有适当的权限

即使具有适当的权限

本文介绍了即使具有适当的权限,Android HTTP连接也会拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的清单中有这个

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.*****.****">
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

以及doInBackground中的这段代码(我知道HttpGet已弃用)

and this code in doInBackground (I know HttpGet is deprecated)

        HttpClient httpclient = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        URI website = new URI(url);
        request.setURI(website);
        HttpResponse response = httpclient.execute(request);

获取org.apache.http.conn.HttpHostConnectException:与 http://127.0.0.1:8080 的连接拒绝错误.帮帮我

getting org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1:8080 refused error. Help me

推荐答案

ip地址127.0.0.1表示回送.找到正确的IP地址.

the ip addres 127.0.0.1 mean loopback.find right ip address.

什么是回送: https://en.wikipedia.org/wiki/Loopback

这篇关于即使具有适当的权限,Android HTTP连接也会拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:25