Skip to content

Commit ee1db21

Browse files
committed
see 02/21 log
1 parent 6276f69 commit ee1db21

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

utilcode/src/main/java/com/blankj/utilcode/utils/KeyboardUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ public static void showSoftInput(EditText edit) {
9999
edit.setFocusable(true);
100100
edit.setFocusableInTouchMode(true);
101101
edit.requestFocus();
102-
InputMethodManager imm = (InputMethodManager) Utils.getContext()
103-
.getSystemService(Context.INPUT_METHOD_SERVICE);
102+
InputMethodManager imm = (InputMethodManager) Utils.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
103+
if (imm == null) return;
104104
imm.showSoftInput(edit, 0);
105105
}
106106

107107
/**
108108
* 切换键盘显示与否状态
109109
*/
110110
public static void toggleSoftInput() {
111-
InputMethodManager imm = (InputMethodManager) Utils.getContext()
112-
.getSystemService(Context.INPUT_METHOD_SERVICE);
111+
InputMethodManager imm = (InputMethodManager) Utils.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
112+
if (imm == null) return;
113113
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
114114
}
115115
}

0 commit comments

Comments
 (0)