Android soft keyboard is disabled and to enable and soft keyboard

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_31433709/article/details/102599529

Recently participated in a project, the main need to adapt to the small screen models with physical keyboard, as the reason for the small screen, so you can not use software disk, but need to use the physical keyboard to input operation.

Looking for a long time, finally we found a relatively appropriate method:
 

在BaseActivity里禁用软键盘
getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

在需要打开的Activity取消禁用软键盘
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

This part of the package where it functions directly in the Application, and then call on the line.

reference:

Android soft keyboard is disabled and to enable and soft keyboard: https://www.jianshu.com/p/5d002b436e0f 

Guess you like

Origin blog.csdn.net/qq_31433709/article/details/102599529
Recommended