I have Android WebView which displays search results. Using the contextMenu and WebView HitTestResult, I have successfully implemented a list of options like open, save, copy link url.
Now, I would like to implement copy link text feature as present in Google chrome android which should copy only link text (title). A similar(not exact) feature is present in default Android browser as “Select text” option.
I don’t want the code for copying text using clipboard instead my main motto is to determine the way of retrieving the link title.
The link url can be retrieved using HitTestResult getExtra() method likewise is there any way to retrieve the link text (title) ?
I have referred How to get loaded web page title in Android WebView? but it gives title after the webpage is loaded not when the link is pressed.
Unfortunately, the link you posted is the fastest way to get the page title (you may refer to the second answer, which is probably faster).
The reason behind this is that a website needs to be loaded before you can read the page title. The advantage of
What chrome does with Copy link text is to copy the text of the link like this:
This is very difficult to achieve via a webview, since you need access to the html-content of the webpage. There are some workarounds out there (see here).
A clear, official way to do this is not available.
Answered By – Manuel Allenspach