Website does not open in my Webview

Asked

Viewed 168 times

2

I made a browser using Webview, but when I call loadUrl(); it opens the page in the default Android browser.
How do I open it inside my browser?

1 answer

3


You need to define where it will open, for example:

WebView myWebView = (WebView) rootView.findViewById(R.id.webView);
myWebView.getSettings().setJavaScriptEnabled(true);

myWebView.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
myWebView.setWebViewClient(new MyWebViewClient());
myWebView.getSettings().setUseWideViewPort(false);
myWebView.loadUrl(url);

This forces the URL to be opened in your XML declared Webview.

Hugs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.