简体   繁体   中英

Android Connection Refused on localhost

It's not a question but a help for everyone get Connection Refused in his Android application when access to a file on his localhost width adress like [http://127.0.0.1:8080]

Perhaps this could help anyone:

If you want to access to a file on your computer width adt emulator, don't use the default ip [127.0.0.1] cause it's the ip of the device emulator.

Add a line on your apache configuration: listen *:8080, then use your computer adress in the httpget (for example HttpGet("[http://192.168.1.1:8080]") without []). You can find your IP adress when typing ipconfig in CMD console

Sorry for some langage errors, I hope you understand me ;-) Bye

or you can use the loopback ip 10.0.2.2 . This is useful when you're working in a team and the other members have different IPs (--> Referring to localhost from the emulated environment )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM