i want allow user to select some texts from webview and it need to be send as a text message. pls find way to select text and copy to clipboard and extracting from clipboard. i saw many example but nothing helped me really…TIA
Edit
using the code provided in the link from @orangmoney52. with following changes
getmethod’s second parameter and invoke method second parameter. if i give null there warning will come.. which one is correct?
public void selectAndCopyText() {
try {
Method m = WebView.class.getMethod("emulateShiftHeld", Boolean.TYPE);
m.invoke(BookView.mWebView, false);
} catch (Exception e) {
e.printStackTrace();
// fallback
KeyEvent shiftPressEvent = new KeyEvent(0,0,
KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(this);
}
}
Getting this error:
05-26 16:41:01.121: WARN/System.err(1096): java.lang.NoSuchMethodException: emulateShiftHeld
The above answers looks perfectly fine and it seems you’re missing something while selecting text. So you need to double check the code and find your overridden any TouchEvent of webview.
i Tried below code it works fine…
Function is
Call Above method wherever you want (You can put a button and call this method in its click event): emulateShiftHeld(mWebView);