网上资料一大堆,拼拼凑凑应该能解决,我的思路比较简单:
WindowManagerService.java
boolean computeScreenConfigurationLocked(Configuration config) {
...
// Determine whether a hard keyboard is available and enabled.
boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
if (hardKeyboardAvailable != mHardKeyboardAvailable) {
mHardKeyboardAvailable = hardKeyboardAvailable;
mHardKeyboardEnabled = hardKeyboardAvailable;
mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
}
if (!mHardKeyboardEnabled) { // 这里是关键
config.keyboard = Configuration.KEYBOARD_NOKEYS;
}
// Let the policy update hidden states.
config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO;
config.navigationHidden = Configuration.NAVIGATIONHIDDEN_NO;
mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
...
}
config.keyboard = Configuration.KEYBOARD_NOKEYS;配置了就能弹出软键盘,你可以写个property配置,也可以干掉这个if,无论是否有物理键盘都能弹出软键盘了。
true
初始化的时候配置:
DatabaseHelper.java
private void loadSecureSettings(SQLiteDatabase db) {
...
loadBooleanSetting(stmt, Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD,
R.bool.def_show_ime_with_hard_keyboard);
...
}