Android: Programatically trigger text selection mode in a WebView on Jelly Bean

纵饮孤独 提交于 2019-11-30 20:33:31
Martin

I have listed a potential solution in the comments here: How to enable the default highlight menus in android webview?

Here is the content of the potential solution: After analyzing android.webkit.WebViewClassic I have had some success with the following:

KeyEvent enterEvent = new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_ENTER,0,0);
enterEvent.dispatch(this); 

I thought more might be required as I needed to scroll down the WebView a little before the above worked when using an emulator, but after testing on a real JellyBean device the above seems to work fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!