Android HTTP connection refused error even after a

2019-07-23 04:40发布

问题:

I have this in my manifest

<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" />

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

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

回答1:

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

what is loopback: https://en.wikipedia.org/wiki/Loopback