How can I intercept link click within WebView?

1

In my Android application, I have a webview that opens several different websites.

Everything works in compliance, however when you have a link on the page, and the user clicks on that link, the browser opens.

I wonder if there is any click event on the elements that are inside the webview, or if there is any other way to handle those clicks within the app.

My intention is to open everything inside the webview, so the user does not exit the application

    
asked by anonymous 20.07.2017 / 14:24

1 answer

0

Create a CustomWebview class that inherits from Webview and traps the click on the navigating event.

Ex:

    public class CustomWebView: WebView
    {
        public String Code { get; set; }

        public CustomWebView()
        {
            Navigating += CustomWebView_Navigating;
        }


        private void CustomWebView_Navigating(object sender, WebNavigatingEventArgs e)
        {
              //Faz alguma coisa
        }
    }

After a look at this link, maybe it will help you! link

    
20.07.2017 / 20:50