本文介绍了Android的嵌入式浏览器无法连接到服务器上的LAN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有带嵌入式浏览器的一个简单的Android应用程序。在这里,它是:
I've got a simple android app with an embeded browser. Here it is:
WebView webview = new WebView(this);
setContentView(webview);
webview.loadUrl("192.168.1.106");
我上运行192.168.1.106的Web服务器。此服务器是活着,以及和可通过手机上的Web浏览器。当我启动应用程序,我收到了找不到网页。如果我改变了应用:
I'm running a web server on '192.168.1.106'. This server is alive and well and accessible through the web browser on the phone. When I start the app I get a 'Web Page not Available'. If I change the app to:
webview.loadUrl("http://google.com");
一切正常。我缺少的东西吗?
everything works. Am I missing something?
推荐答案
您必须指定的http://
即使是使用IP
You have to specify http://
even when IP is used.
webview.loadUrl("http://192.168.1.106");
要强制网页总是加载到的WebView(未外部浏览器),在使用loadURL
呼叫前加入这一行。
To force the webpage to always load into WebView (not external browser), add this line before the loadUrl
call.
viewer.setWebViewClient(new WebViewClient());
看到这个答案:
这篇关于Android的嵌入式浏览器无法连接到服务器上的LAN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!