我正在使用xampp apache服务器从我的机器为应用程序提供资源.但我得到了上述错误.
我在谷歌上得到了一些东西.指向可能的解决方案 http://groups.google.com/group/android-beginners/browse_thread/thread/599a06416fb37b4a
上述问题的解决方案是什么?
小智 22
在android中
更换: String webServiceUrl = "http://localhost:8080/Service1.asmx"
用: String webServiceUrl = "http://10.0.2.2:8080/Service1.asmx"
祝好运!
sko*_*lis 19
localhost和127.0.0.1都是说"当前机器"的方式.因此,PC上的localhost是PC,而android上的localhost就是手机.由于您的手机当然没有运行网络服务器,它将拒绝连接.
您需要获取计算机的IP地址(在Windows上使用ipconfig查找)并使用它而不是127.0.0.1.这可能仍然无法正常工作,具体取决于您的网络/防火墙的设置方式.但这是一个完全不同的话题.
您只需使用本地(但真实)的IP地址和端口号,如下所示:
String webServiceUrl = "http://192.168.X.X:your_virtual_server_port/your_service.php"
并确保您确实在清单中设置了Internet权限
<uses-permission android:name="android.permission.INTERNET" />
小智 9
uses-permission android:name ="android.permission.INTERNET
如果您在 url 中使用 localhost 并在 emulator 中测试您的应用程序,只需将系统的 ip 地址替换为 URL 中的 localhost。或者您可以使用 10.0.2.2 代替 localhost。
http://localhost/webservice.php到http://10.218.28.19/webservice.php
其中 10.218.28.19 -> 系统的 IP 地址。
或者
http://localhost/webservice.php到http://10.0.2.2/webservice.php
| 归档时间: |
|
| 查看次数: |
176373 次 |
| 最近记录: |