Webview, startActionMode() is not called

心已入冬 提交于 2019-12-11 15:05:49

问题


I need to have a customized text selection menu (CAB) in my Webview.
As this question is answered, I override startActionMode method, and it works fine

THE PROBLEM:

In some devices (two huawei devices as far as I tested) webview shows android default menu, and startActionMode method is not called at all.
I override other methods and the only method which gets called when I select some text is showContextMenu().

I considered using a JS solution for this case, but I prefer to solve the issue simpler and with a native solution.

Moreover when I override showContextMenu() method, I noticed the stack trace is different in devices which work fine and the ones not.

stack trace for devices work fine:

    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)

stack trace for devices not working fine:

    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:


According to the issue I posted on Google issue tracker; https://issuetracker.google.com/issues/79394037 the statue of this issue is wont fix Status: Won't Fix (Intended Behavior)



来源:https://stackoverflow.com/questions/50199760/webview-startactionmode-is-not-called

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