问题
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?
回答1:
Make sure you are not using "localhost" from you app (a very common mistake).
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.
If you are using the emulator, try with 10.0.2.2
See here Accessing localhost:port from Android emulator
回答2:
I too had the same issue. Let's say the IP address is `216.58.216.164. I rectified it using following
webView.loadUrl("http://216.58.216.164/")
来源:https://stackoverflow.com/questions/15103463/how-to-access-the-local-host-server-with-web-view-in-android