1

I want to copy selected text in android WebView, I tried many methods to do this but nothing done. like :

 android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   KeyEvent shiftPressEvent = new KeyEvent(0, 0,
               KeyEvent.ACTION_DOWN,
               KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
            shiftPressEvent.dispatch(webview);

            if(clipboard!=null)
            {
              String text = clipboard.getText().toString();
              Toast.makeText(this, "select_text_now     "+text, Toast.LENGTH_LONG).show();
            }

Many Thanks;

Ayman
  • 81
  • 2
  • 10
  • Take a look at this answer: http://stackoverflow.com/questions/6058843/android-how-to-select-texts-from-webview/29353049#29353049 – vikoo Mar 30 '15 at 18:12

1 Answers1

1

According to this link
Copy Text in a WebView in Android 2.3 and Below Copy functionality in a WebView is available by default in Android 3.0 and above,
and may be this information may be help, Android: how to select texts from webview
Edit
To Override text selection this post may help you
Override onLongTouch in a WebView, but keep text selection

Community
  • 1
  • 1
Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
  • OK,(available by default in Android 3.0 and above) but how can i override this default copy to use it in my code. – Ayman Jun 01 '14 at 11:50