用于删除导致 Speech-To-Text 失败的图像的 Android Webview 策略 [英] Android Webview Strategy For Deleting Images Causing Speech-To-Text to Fail

查看:18
本文介绍了用于删除导致 Speech-To-Text 失败的图像的 Android Webview 策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:无法在 Android 上的 contenteditable div 中删除图像

目前唯一已知的解决方案:Android:WebView/BaseInputConnection 中的退格

Only known solution at the moment: Android: Backspace in WebView/BaseInputConnection

解决方案问题:设置:使用常规构造函数创建 BaseInputConnection 似乎会禁用语音到文本的正常运行.而不是使用 WebView.onCreateInputConnection(EditorInfo) 生成 InputConnection.

Problem with solution: Setting: creating a BaseInputConnection using the regular constructor seems to disable speech to text from functioning correctly. as opposed to using WebView.onCreateInputConnection(EditorInfo) to generate an InputConnection.

有什么想法可以解决这个问题吗?

any ideas how to remedy this?

推荐答案

我在使用 SwiftKey 完成文本时也遇到了同样的问题.为了修复它,您必须记住一些事情:

I had the same issue also with text completion using SwiftKey. In order to fix it you must remember some things:

  • 您必须扩展 BaseInputConnection 并包装原始 webview 的 InputConnection
  • 不要使用 InputConnectionWrapper,因为它会导致其他问题
  • 你需要继承第二个方法:commitText

  • you must extend BaseInputConnection and wrap the original webview's InputConnection
  • don't use InputConnectionWrapper as it will cause other problems
  • you need to subclass a second method: commitText

public boolean commitText(CharSequence text, int newCursorPosition) {

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        return orig.commitText(text, newCursorPosition);

    } else {
        // pre-kitkat workaround 
        boolean res = true;
        for (int i = 0; i < text.length(); i++) {
            res = orig.commitText(text.subSequence(i, i+1), newCursorPosition);
        }
        return res;
    }
}

这篇关于用于删除导致 Speech-To-Text 失败的图像的 Android Webview 策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆