open external webview link

Asked

Viewed 1,133 times

-1

I have a webview app that is made 100% of webview, but 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 site that opens an app, but trying to open inside the webview and is giving error, then you have to open out of it... how to do ?

  • You want the link to open an application on Android device?

  • Yeah, I made a website, then I put it on the webview.. and it has a href with Intent, I want you to click this ahref with Intent open an external page and doing this it will open the app

  • See https://developer.android.com/training/app-links/index.html

1 answer

0

I used the following code in a context menu in a list, it uses the default user browser. maybe it can help a little to adapt 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);

Browser other questions tagged

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