如何在Android中使用Web视图访问本地主机服务器 [英] How to access the local host server with web view in Android

查看:105
本文介绍了如何在Android中使用Web视图访问本地主机服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序,我需要转到我的Web服务器并将我的Android应用程序连接到网络上的另一个程序.我的网络程序正在运行,当我将其IP地址放在Android FIrefox或浏览器上时,它正在运行,但是当我使用webview调用其IP地址(webView.loadUrl(我的网络程序IP地址)时,它无法运行.有人可以帮助我在哪里是我的错误吗?

I have an Android Application and I need to go to my web server and connect my Android Application to another program on the web. my web program is working and when I put its IP address on Android FIrefox or Browser it is working but when I call its IP address with my webview ( webView.loadUrl(my web program IP address) it's not working. Can somebody help me where is my mistake?

推荐答案

请确保您没有在应用中使用"localhost"(这是一个非常常见的错误).

Make sure you are not using "localhost" from you app (a very common mistake).

如果您要通过wifi访问本地服务器,则只需检查服务器已分配的IP,然后在应用程序中使用它即可.

If you are accessing your local server from a wifi, you just need to check which IP your server has assigned and use it in the app.

如果您使用的是仿真器,请尝试使用10.0.2.2

If you are using the emulator, try with 10.0.2.2

请参见从Android仿真器访问localhost:port

这篇关于如何在Android中使用Web视图访问本地主机服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆