List of usage examples for android.app Activity getSystemService
@Override
public Object getSystemService(@ServiceName @NonNull String name)
From source file:Main.java
public static void dismissKeyBoard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isAcceptingText()) { // verify if the soft keyboard is open imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }// w w w . ja v a 2s.co m }
From source file:Main.java
public static void hideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); }
From source file:Main.java
public static void dismissKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE); if (imm.isAcceptingText()) { // verify if the soft keyboard is open imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }//from w w w. java2 s .c om }
From source file:Main.java
public static boolean isOnline(Activity activity) { ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnectedOrConnecting(); }
From source file:Main.java
public static void closeInputMethodWindow(Activity activity) { try {// ww w. j av a 2 s. c o m ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Throwable th) { th.printStackTrace(); } }
From source file:Main.java
public static void hideMethod(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static void hideSoftKeyboard(Activity activity) { InputMethodManager manager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); manager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }
From source file:Main.java
public static void hideKkeyboard(Activity activity) { try {/*ww w .jav a 2 s. c o m*/ ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void hideKeyboard(Activity activity) { try {// www. j av a 2 s. co m ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void dismissSoftKeyBoard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); }//from w ww .ja va2s .com }