Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android webview can't connect to local ip address

I've got a webView class in a simple android app. I'm trying to get webView to load a webpage hosted on a server on my local network and it can't connect.

WebView webview = new WebView(this);
setContentView(webview);
webview.loadUrl("192.168.1.104");

webView says 'web page not available'

I can connect to 192.168.1.104 in a regular browser and any mobile browser. When I replace 192.168.1.104 with http://example.com it works.

like image 769
Francis Snipe Avatar asked Mar 25 '23 09:03

Francis Snipe


1 Answers

Did you add the internet permission to the AndroidManifest.xml?

<uses-permission android:name="android.permission.INTERNET"/> 
like image 177
Stefan Avatar answered Apr 09 '23 17:04

Stefan