Question with webview, open more than one link outside the app

0

I tried to set my webview to open more than one link, but it does not work

My code causes websites.google to open in the app's webview and the rest of the links open outside (android nav), I want sites.google and photos.google to open in the app's webview

private class MyWebviewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (Uri.parse(url).getHost().equals("sites.google.com")) {
            //abrir no meu webview            AQUI EU GOSTARIA DE ADC OUTRO
            return false;                     LINK PARA ABRIR NO MEU WV
        } else {
            //restante dos links abrir no navegador
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }

    }

An example

public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (Uri.parse(url).getHost().equals("sites.google.com") && ("photos.google.com")) {

But this does not work, can you do that? If so, does anyone know another way?

    
asked by anonymous 17.11.2017 / 17:05

1 answer

0

My Solution

@Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (Uri.parse(url).getHost().equals("sites.google.com")) {
            //open url contents in webview
            return false;
        }if (Uri.parse(url).getHost().equals("photos.google.com")) {
            //open url contents in webview
            return false;
    } else {
            //here open external links in external browser or app
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }

    }

If someone has another solution, I'd like to see it.

    
17.11.2017 / 17:11