Webview,startActionMode()未被调用

时间:2018-05-06 12:35:24

标签: android webview cab

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

问题:

在某些设备中(据我测试的两个华为设备)webview显示了android默认菜单,并且根本没有调用startActionMode方法。 我覆盖了其他方法,当我选择一些文本时,唯一被调用的方法是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.access$601(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.access$7000(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.access$300(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.access$601(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.access$1500(ContentViewGestureHandler.java:29)
    at com.android.org.chromium.content.browser.ContentViewGestureHandler$1.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$000(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)

1 个答案:

答案 0 :(得分:0)

根据我在Google问题跟踪器上发布的问题; https://issuetracker.google.com/issues/79394037此问题的解决方法无法解决 状态:无法解决(预期行为)