Tracking text selection in an Android browser

In the Android web browser, we can select the text on the web pages. After completing the selection, the toast will appear as "text copied to the clipboard." Can this toast be avoided? I also want to call the function after selecting the text. How can i do this?

help me...

+6
source share
1 answer
public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == android.view.MotionEvent.ACTION_UP) { // when user finished selection this loop will execute to get // selected text in webview. if(mark_text == true) { mark_text = false; clipboardManager.setText("XXXXXX"); webView.postDelayed(onClipBoard, 1000); } } } private Runnable onClipBoard=new Runnable() { public void run() { // if selected text is copied in clipboard toast will show the // correct text otherwise else part will execute if (!clipboardManager.getText().toString().equalsIgnoreCase("XXXXXX")) { Toast.makeText(getApplicationContext(), "selected Text = " + clipboardManager.getText().toString(), Toast.LENGTH_LONG).show(); clipboardManager.setText("XXXXXX"); } else { webView.postDelayed(onClipBoard, 1000); } } }; 
+5
source

Source: https://habr.com/ru/post/903756/


All Articles