open external link webview

0

I have a webview app that is made 100% of the webview, however I want to open some links outside the app, for example, the links that start with intent, in case I want to put a button on the website that opens an app, but ta trying open within the webview and is giving error, then have to make it open out of it ... how to do?

    
asked by anonymous 08.11.2017 / 12:08

1 answer

0

I used the following code in a context menu in a list, it uses the user's default browser. maybe it might help a little to fit it on a button.

    MenuItem itemSite = menu.add("Visitar Site");
    Intent intentSite = new Intent(Intent.ACTION_VIEW);
    //coloca o https na frente
    String site = suaURL;
    if (!site.startsWith("http://")) {
        site = "http://" + site;
    }
    //seta o site
    intentSite.setData(Uri.parse(site));
    itemSite.setIntent(intentSite);
    
08.11.2017 / 13:41