关于Android模拟键盘使用的注意事项

来源:互联网 发布:西安少儿编程培训班 编辑:程序博客网 时间:2024/04/30 01:03
调用getCurrentInputConnection()需要继承InputMethodService类。

利用输入法 

getCurrentInputConnection().commitText("文本", "文本".length());

//以下两句为模拟回车

getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN,66));

getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP,66));

原创粉丝点击