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

Asked

Viewed 227 times

0

I tried my set my webview to open more than one link, but n works

my code makes websites.google open in the webview of the app and the rest of the links open out(android Nav), I want the sites.google and photos.google open in the webview of the app

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 that doesn’t work, is there any way to do it? if yes someone knows another way?

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 anyone has another solution I’d like to see.

Browser other questions tagged

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