File tree 1 file changed +4
-4
lines changed
utilcode/src/main/java/com/blankj/utilcode/utils
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -99,17 +99,17 @@ public static void showSoftInput(EditText edit) {
99
99
edit .setFocusable (true );
100
100
edit .setFocusableInTouchMode (true );
101
101
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 ;
104
104
imm .showSoftInput (edit , 0 );
105
105
}
106
106
107
107
/**
108
108
* 切换键盘显示与否状态
109
109
*/
110
110
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 ;
113
113
imm .toggleSoftInput (InputMethodManager .SHOW_FORCED , 0 );
114
114
}
115
115
}
You can’t perform that action at this time.
0 commit comments