Android Question Open External Link in Default Browser

Discussion in 'Android Questions' started by Ederson Kerber, Apr 9, 2019.

  1. Ederson Kerber

    Ederson Kerber Member Licensed User

    I have a webview displaying an html page (locally stored). The html page has an image that contains an external link to my app, ex: https://www.google.com/

    I need to click on the image that contains the link (https://www.google.com/), it will open in the default android browser and not in the webview inside my app.

    Thanks!
     
  2. DonManfred

    DonManfred Expert Licensed User

    You should use webview and use the overrideurl event.
     
    Last edited: Apr 10, 2019
  3. Erel

    Erel Administrator Staff Member Licensed User

    The OverrideUrl is part of WebView. No need to use WebViewExtras for this.

    Use PhoneIntents from the Phone library to open the browser.
     
  4. DonManfred

    DonManfred Expert Licensed User

    sorry. removed...
     
  5. Ederson Kerber

    Ederson Kerber Member Licensed User

    Hi

    Thank you for the tips. But the proposed solution does not meet my need. PhoneIntents opens the link in the browser when the link is not inserted into the html file - I already use it for other projects:
    Code:
    StartActivity (pi.OpenBrowser ("https://www.google.com"))
    .

    However, what I need is: When I click the button, the app will open the html file in a webview. In the open html in webview has a link that should be open in the default browser and not inside the webview itself.

    Attachment 3 project images:
    1 - Start screen with the button to click and open the html file;
    2 - Webview with open html;
    3 - Link(www.google.com) that is in the html open in the webview, but should be opened in the default browser.

    P.S: I tried attaching a sample project example.zip (634KB), however, I received the following error: "The following error occurred: The uploaded file is too large". If you can send it any other way, please let me know.

    Thanks!
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      39 KB
      Views:
      35
    • 2.jpg
      2.jpg
      File size:
      141.8 KB
      Views:
      34
    • 3.jpg
      3.jpg
      File size:
      82.1 KB
      Views:
      28
  6. DonManfred

    DonManfred Expert Licensed User

    Use the override url event of the webview to catch the click.

    Code:
    Sub WebView1_OverrideUrl (Url As StringAs Boolean
    StartActivity (pi.OpenBrowser (url))
    Return True
    End Sub
     
    Erel likes this.
  7. Ederson Kerber

    Ederson Kerber Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice