Webview,startActionMode() 未被调用

Webview, startActionMode() is not called

我需要在我的 Webview 中有一个自定义文本 selection 菜单 (CAB)。
当回答 this question 时,我重写了 startActionMode 方法,它工作正常

问题:

在某些设备(据我测试的两个华为设备)中,webview 显示 android 默认菜单,并且根本不调用 startActionMode 方法。
我覆盖了其他方法,并且当我 select 某些文本时唯一被调用的方法是 showContextMenu()

我考虑过在这种情况下使用 JS 解决方案,但我更愿意使用本机解决方案更简单地解决问题。

此外,当我重写 showContextMenu() 方法时,我注意到堆栈跟踪在工作正常的设备和不工作的设备中是不同的。

设备的堆栈跟踪工作正常:

    at com.rose.iknitoreader.views.ReaderWebView.showContextMenu(ReaderWebView.java:65)
    at android.view.View.performLongClick(View.java:4279)
    at android.webkit.WebView.access1(WebView.java:239)
    at android.webkit.WebView$PrivateAccess.super_performLongClick(WebView.java:1775)
    at android.webkit.WebViewClassic.performLongClick(WebViewClassic.java:4455)
    at android.webkit.WebView.performLongClick(WebView.java:2105)
    at com.rose.iknitoreader.views.ReaderWebView.performLongClick(ReaderWebView.java:60)
    at android.webkit.WebViewClassic.onHandleUiEvent(WebViewClassic.java:1354)
    at android.webkit.WebViewClassic.access00(WebViewClassic.java:146)
    at android.webkit.WebViewClassic$PrivateHandler.dispatchUiEvent(WebViewClassic.java:7655)
    at android.webkit.WebViewInputDispatcher.dispatchUiEvent(WebViewInputDispatcher.java:841)
    at android.webkit.WebViewInputDispatcher.dispatchUiEvents(WebViewInputDispatcher.java:829)
    at android.webkit.WebViewInputDispatcher.access0(WebViewInputDispatcher.java:78)
    at android.webkit.WebViewInputDispatcher$UiHandler.handleMessage(WebViewInputDispatcher.java:1118)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)

设备无法正常工作的堆栈跟踪:

    at com.rose.iknitoreader.views.ReaderWebView.showContextMenu(ReaderWebView.java:60)
    at android.view.View.performLongClick(View.java:4496)
    at android.webkit.WebView.access1(WebView.java:258)
    at android.webkit.WebView$PrivateAccess.super_performLongClick(WebView.java:1988)
    at com.android.webview.chromium.WebViewChromium.performLongClick(WebViewChromium.java:1690)
    at android.webkit.WebView.performLongClick(WebView.java:2365)
    at com.android.org.chromium.content.browser.ContentViewCore.offerGestureToEmbedder(ContentViewCore.java:3451)
    at com.android.org.chromium.content.browser.ContentViewCore.sendGesture(ContentViewCore.java:1426)
    at com.android.org.chromium.content.browser.ContentViewGestureHandler.sendMotionEventAsGesture(ContentViewGestureHandler.java:1078)
    at com.android.org.chromium.content.browser.ContentViewGestureHandler.access00(ContentViewGestureHandler.java:29)
    at com.android.org.chromium.content.browser.ContentViewGestureHandler.onLongPress(ContentViewGestureHandler.java:582)
    at com.android.org.chromium.content.browser.ContentViewGestureHandler.onLongPress(ContentViewGestureHandler.java:625)
    at com.android.org.chromium.content.browser.LongPressDetector.dispatchLongPress(LongPressDetector.java:157)
    at com.android.org.chromium.content.browser.LongPressDetector.access[=11=]0(LongPressDetector.java:21)
    at com.android.org.chromium.content.browser.LongPressDetector$LongPressHandler.handleMessage(LongPressDetector.java:58)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5291)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)

根据我在 Google 问题跟踪器上发布的问题; https://issuetracker.google.com/issues/79394037 这个问题的状态不会修复 状态:无法修复(预期行为)