今天遇到了一个问题:在平板中开发项目的时候,弹出软键盘后finish掉activity后软键盘依然存在的问题。之前的解决思路是在Activity的onDestory方法中监测软键盘是否存在,存在则回收,试了一下存在问题,无法判断软键盘是否显示;目前的解决方案是:在点击回退按钮的时候响应系统的back键,在点击事件中执行:
new Thread () {
public void run () {
try {
Instrumentation inst= new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent. KEYCODE_BACK);
} catch(Exception e) {
e.printStackTrace();
}
}
}.start();
参考文章:https://blog.csdn.net/sinat_31311947/article/details/53899166,https://blog.csdn.net/qq_36487432/article/details/82226125