【发布时间】:2014-10-18 05:50:24
【问题描述】:
我正在尝试实现自己的 android 输入法。在InputMethodService.onStartInputView 中,我保存了对InputConnection 的引用,该引用由getCurrentInputConnection 返回以供以后使用。在 keyup 事件中,我调用 InputConnection.commitText 将一些文本提交到屏幕上。
但我发现在某些应用程序中,该函数调用无效(即屏幕上什么都没有出现)而
softKeyBoard sdk 示例运行良好。唯一的区别是样本使用getCurrentInputConnect 来提交字符。此外,我的应用程序中的声明是 false
mCurrentInputConnection == Ime.getCurrentInputConnection()
在 IME 服务的source code 中,有两个 InputConnection 成员:mInputConnection 和 mStartedInputConnection,getCurrentInputConnection 可能会返回任何一个。
我知道我每次都可以调用getCurrentInputConnection,但我只是想避免因性能问题而调用函数(因为调用过于频繁)。那么有没有其他方法来获得正确 InputConnection? (两者有什么区别?)
【问题讨论】:
标签: android android-input-method