Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView click open within WebView not a default browser

I did one sample application using WebView, in that web view the URL comes from web services. It's working fine, but if I click any link within that WebView, its automatically go for default web browser. But I want to open within my application web view only. Here my code:

WvBikeSite = (WebView) findViewById(R.id.wv_bikeWebsite); wvBikeSite.loadUrl(getBundle.getString("www")); 
like image 741
selva Avatar asked Apr 03 '12 03:04

selva


People also ask

What is the difference between WebView and browser?

What is WebView? Simply put, Android WebView allows apps to display web content, without having to open a web browser. Up to Android 6, WebView was a system service. Then, with Android 7.0, Google incorporated that functionality into the default Chrome Browser.

How do I open WebView in Chrome?

# Open a WebView in DevToolsThe chrome://inspect page displays a list of debug-enabled WebViews on your device. To start debugging, click inspect below the WebView you want to debug. Use DevTools as you would for a remote browser tab.

How do I turn off click on WebView?

Open Play Store on your device, search for Android System WebView and click on it. Now you can see the option of Disable, press it, the app is now disabled.


1 Answers

You have to set up a webViewClient for your webView.

Sample:

this.mWebView.setWebViewClient(new WebViewClient(){      @Override     public boolean shouldOverrideUrlLoading(WebView view, String url){       view.loadUrl(url);       return true;     } }); 
like image 72
Terence Lui Avatar answered Oct 14 '22 01:10

Terence Lui