关于 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 !

posted @ 2010-12-01 15:52  兵库合力  阅读(1973)  评论(0编辑  收藏  举报