Skip to content Skip to sidebar Skip to footer

Webview And Localhost

I am getting google.com inside my WebView, but am not getting my localhost in that. Can anybody help me?

Solution 1:

Use 10.0.2.2 instead. This is a special ip address that the emulator routs to local host on your dev machine. assuming that emulator and the webserver are running on the same machine.

Solution 2:

Make sure you are loading WebView with full Urls.

http://www.google.com
http://10.0.2.2/

and not:

www.google.com
google.com

All of these will work while using Browser, but you must supply a full valid url for WebView. Banged my head against the keyboard for an hour figuring that out.

If you're having connectivity issues in the emulator, try overriding the dns in the build path.

Window> Preferences > Android > Launch
Default emulator options: -dns-server 8.8.8.8

Solution 3:

I have created a website and published it in my local computer using IIS, I tried to access this site in the android emulator using WebView:

http://localhost:83

with the same results as the OP.

I changed to:

http://10.0.2.2:83

and worked.

Solution 4:

Try your actual ip [with the port number if required] instead of localhost.

Solution 5:

Just type localhost name and port like this: http://127.0.0.1:80

Post a Comment for "Webview And Localhost"