Android 模拟器中的 Web 浏览器中的 10.0.2.2:8080 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21510311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
10.0.2.2:8080 in web browser in emulator is not working
提问by IhtkaS
I have a wamp server in localhost. I tried to make http request from my android app. But cannot get it right. Many said 10.0.2.2:8080 will point to localhost from emulator. So i tried to open it in web browser from emulator. i typed in url as "10.0.2.2/cifi/test.php". But emulator popped error as "net:CONNECTION_TIMED_OUT"
我在本地主机中有一个 wamp 服务器。我试图从我的 android 应用程序发出 http 请求。但不能正确。许多人说 10.0.2.2:8080 会从模拟器指向 localhost。所以我试图从模拟器在网络浏览器中打开它。我输入的网址为“10.0.2.2/cifi/test.php”。但模拟器弹出错误为“net:CONNECTION_TIMED_OUT”
Need explanation: how to make my wamp server in local machine to listen 10.0.0.2:8080 from emulator's browser.
需要解释:如何让我的本地机器上的 wamp 服务器从模拟器的浏览器中监听 10.0.0.2:8080。
采纳答案by IhtkaS
It finally worked! I used "10.0.2.2:80/cifi/test.php". My wamp server listens only to that port. Thanks to everyone who wanted to help me!
它终于奏效了!我使用了“10.0.2.2:80/cifi/test.php”。我的 wamp 服务器只监听那个端口。感谢所有想帮助我的人!
回答by TheCopycat
Your Wamp Server seems to be accepting only localhost connections.
您的 Wamp 服务器似乎只接受本地主机连接。
Left click on wamp icon -> put online
左键单击 wamp 图标 -> 联机
Additionnally you should type a url http://10.0.2.2:8080/cifi/test.php
instead of http://1.0.2.2/cifi/test.php
另外你应该输入一个网址http://10.0.2.2:8080/cifi/test.php
而不是http://1.0.2.2/cifi/test.php
回答by Orkhan Alikhanov
Weirdlyenough, in my case, I had to turn on and off the airplane modeto get it working.
奇怪的是,就我而言,我必须打开和关闭飞行模式才能使其正常工作。