【发布时间】:2014-10-13 17:59:59
【问题描述】:
是否可以在主机 Android 应用程序中处理来自 web 视图的软件键盘事件?
例如,我的应用程序的 Activity 是否可以在显示 Google 网站的 webview 的搜索字段中侦听键入的内容?
考虑到下面描述的方法,如果我覆盖它返回 true,这将是可能的,但不幸的是我无法做到。有什么想法吗?
public boolean shouldOverrideKeyEvent (WebView view, KeyEvent event)
Added in API level 1
Give the host application a chance to handle the key event synchronously. e.g. menu shortcut key events need to be filtered this way. If return true, WebView will not handle the key event. If return false, WebView will always handle the key event, so none of the super in the view chain will see the key event. The default behavior returns false.
Parameters
view The WebView that is initiating the callback.
event The key event.
Returns
True if the host application wants to handle the key event itself, otherwise return false
【问题讨论】:
-
你只想为谷歌或所有网站这样做
-
@joaonlima :恐怕如果有可能,就好像这种情况,人们可能能够跟踪在 webview 支付页面中输入的 3-D 安全密码(when-if)(多数民众赞成在例如线说)