There is a WebView, an HTML page is loaded into it, for example, a link or a picture in it. Can I intercept a click on a picture or link and transfer it to the application?

    1 answer 1

    You can intercept URL changes.
    To do this, WebViewClient needs to override the method

    shouldOverrideUrlLoading(WebView view, String url) 

    or

     shouldInterceptRequest(WebView view, String url) 

    I think it is possible to intercept clicks, but not easy. For example, set WebView onTouchListener, in which to determine in some way what element is located on these coordinates.

    UPD:
    How to determine which element is located on given coordinates:

     WebView.loadUrl("javascript:document.elementFromPoint(x, y);"); 

    The result can be returned by embedding JavaScriptInterface in WebView