Android InputMethodService中的两个InputConnection变量?

Android InputMethodService中的两个InputConnection变量?,android,android-input-method,Android,Android Input Method,我正在尝试实现自己的android IME。在InputMethodService.onStartInputView中,我保存了对getCurrentInputConnection返回的InputConnection的引用,以供以后使用。在keyup事件中,我调用InputConnection.commitText将一些文本提交到屏幕上 但我发现在某些应用程序中,函数调用没有效果(即屏幕上没有显示任何内容),而 软键盘sdk示例运行良好。唯一的区别是示例使用getCurrentInputConn

我正在尝试实现自己的android IME。在
InputMethodService.onStartInputView
中,我保存了对
getCurrentInputConnection
返回的
InputConnection
的引用,以供以后使用。在keyup事件中,我调用
InputConnection.commitText
将一些文本提交到屏幕上

但我发现在某些应用程序中,函数调用没有效果(即屏幕上没有显示任何内容),而
软键盘sdk示例运行良好。唯一的区别是示例使用
getCurrentInputConnect
提交字符。此外,我的应用程序中的声明是false

mCurrentInputConnection == Ime.getCurrentInputConnection()
在IME服务中,有两个InputConnection成员:mInputConnection和MsStartedInputConnection,
getCurrentInputConnection
可以返回其中一个


我知道每次都可以调用
getCurrentInputConnection
,但我只是想避免性能问题的函数调用(因为调用太频繁)。那么,是否有其他方法可以获得正确的输入连接?(两者之间的区别是什么?

您的
InputConnection
的单个实例停止工作,因为一旦您打开其他应用程序或更改editText字段,新的客户端已与您的IME绑定,因此输入连接已更改

如果要避免多次调用
getCurrentInputConnection()
,则每次更改时都可以存储
InputConnection
对象。它的回调是