简体   繁体   中英

Open url in webview Android

I make the webview and put it activity.

And set webview,

browser.getSettings().setJavaScriptEnabled(true);

// Set WebView client
browser.setWebChromeClient(new WebChromeClient());

browser.setWebViewClient(new WebViewClient() {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
});
// Load the webpage
browser.loadUrl(url);

I understand that, is there any url in webview, webview detect the url and enable to move that url.

But it had no action.

I want when I load the url in webview, if webview has url text, auto detect it and when I touch that text, enable to move that url.


update

<p style="float: left; width: 116px; text-align: left;"><font color="orange">Homepage</font></p><p style="text-align: left; margin-left: 120px;"><font><?=$Homepage?></font></p>

According to Android documentation (and also to my experience), true return value for shouldOverrideUrlLoading means "don't load this url".

You should not override shouldOverrideUrlLoading unless you want to apply url filtering

view.LoadUrl calls is not needed here, since shouldOverrideUrlLoading is called on each url loading

Android doc : https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM