Based on the comment you've wrote, you've mentioned that you want to extract the text from the website. You'll need to identify which text you want exactly and locate it within the HTML code.
The following solution will allow you to extract the HTML code of the given website but you'll have to narrow it down to exactly which text you want to extract further and in which attribute it's located in i.e. class/id
webView.evaluateJavascript(
"(function() { return ('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>'); })();",
new ValueCallback<String>() {
@Override
public void onReceiveValue(String html) {
Log.d("HTML", html);
// This should log the html code within the log cat
}
});
-Would like to credit Balaji M for the answer under html content in webview as it also contributes this question.-
~~I would like to keep my previous answer in place in case you do decide to change your approach on this question~~
As you've already located the answer to the event listener where you will be able to detect when the copy button is triggered within the webView, the only part of functionality which is missing now is the paste from ClipBoard.
Should put the following code within the onCreate method:
// Gets a handle to the clipboard service.
ClipboardManager clipboardManager = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
Now it's time to copy the data from the clipboard into our String variable or any other variable type.
// Get clip data from clipboard.
ClipData clipData = clipboardManager.getPrimaryClip();
// Get item count.
int itemCount = clipData.getItemCount();
if(itemCount > 0){
// Get source text.
Item item = clipData.getItemAt(0);
String copiedData = item.getText().toString();
//For testing purpose, display toast containig your copied data
Toast.makeText(getActivity(), copiedData , Toast.LENGTH_LONG).show();
}