关于 Android 开发中的 127.0.0.1 Connection refused ...

学习Android有一时间了!有时间就看视频,终于看到了编写代码!本人编程灵性不太够,但是还算努力,所以这节代码看两遍!现在运行没有任何问题!
中间也出现了一些小问题,但是也都被排处了!其中,运行代码时抛出异常 127.0.0.1 Connection refused —— 127.0.0.1 地址被拒绝访问!造成不能问访本机WEB,下载mp3列表失灵!在网上查了一下这个问题 —— http://stackoverflow.com/questions/2301560/java-net-connectexception-127-0-0-18080-an-android-emulator 给出明确的答复:

   

127.0.0.1 is a Android emulated device's own loopback interface.

In other words, you connect to android emulated device (not to your computer) by using 127.0.0.1.

To get connection to your machine with web-server use 10.0.2.2 or real machine IP address (if you have direct access from web).

Use command ipconfig(Windows)/ifconfig(Linux) to obtain your IP address.

Also see official docs or this!

          127.0.0.1 是 Android 模拟器设务自己的回送接口(既localhost)。
          换言之,你不能使用电脑连接android模拟器。
          可以用android内置IP 10.0.2.2 或 用真识IP地址联接电脑。
          获取IP地址:
                    Windows 可用 ipconfig 查询IP !
                    Linux  可用 ifconfig 查询IP !

转载于:https://www.cnblogs.com/king4220550/archive/2010/12/01/1893520.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值