I'm testing an application in the Eclipse emulator which loads a site through a WebView. My problem is that the site is only reachable when I'm connected to my job's VPN, I can access it from my PC's browser but not from the emulator. This is my code:
public class MainActivity extends Activity {
public WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_main);
myWebView = (WebView)this.findViewById(R.id.webView);
myWebView.getSettings().setLoadsImagesAutomatically(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setWebViewClient(new CustomWebViewClient());
myWebView.loadUrl("https://xxx");
}
}
When I tested with "http://google.com" it worked fine, the same when I used a random https site, but when I try to access the VPN site I got a "net::ERR_CONNECTION_TIMED_OUT" error.
I'm already connected to the VPN, and also checked that <uses-permission android:name="android.permission.INTERNET" />
is before the <application>
tag in the manifest. I've tested with Eclipse emulator and BlueStacks App Player, in both cases running the application and entering the URL into the emulators' browser, and got always the same result.
Is there any restrictions for this type of access in Android's emulators?
Thanks in advance, regards.
UPDATE
If I access the IP address from the emulator's browser, I can reach the site, but when I try to load it using myWebView.loadUrl
got the same error
Finally I figured out how to load my site, I put the IP address and the port instead of the URL that you can see in the "hosts" file. Also, I had to override the
onReceivedSslError
method of my CustomWebViewClient because I was getting a certification error when loading my page:Now loadUrl looks like this:
Hope it helps someone else.