I want that when the user clicks the back button, it will go back to the page where it clicked the link. However, in many cases, after you click a link, the website takes you through many background redirects to ads and from page to page until they get you to your destination. In such case when you click the back button, you return to an ad, or to a redirect page.
shouldOverrideUrlLoading
does not provide a solution since it includes all the redirects (webview history is just the same BTW). I tried a combination of
setOnTouchListener and WebView.HitTestResult
to detect whether the page loading is following a link click or an auto redirect but it makes many fault results.
Bottom line, I want to identify all link clicks that open a new page, so I can track the user activity and take the user back on back clicked as necessary.
How to detect whether a page is loaded after a link was actually clicked by the user or just as a loading procedure of the website?
Thanks!