File tree Expand file tree Collapse file tree
utilcode/src/main/java/com/blankj/utilcode/utils Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments