List of usage examples for android.app Activity getSystemService
@Override
public Object getSystemService(@ServiceName @NonNull String name)
From source file:Main.java
/** * This method hides the keyboard// ww w .j a va2 s. c o m * * @param activity * Active activity */ public static void hideKeyboard(Activity activity) { InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View view = activity.getCurrentFocus(); if (view != null) { inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:Main.java
public static void hideKeyboard(Activity activity) { InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); //Find the currently focused view, so we can grab the correct window token from it. View view = activity.getCurrentFocus(); //If no view currently has focus, create a new one, just so we can grab a window token from it if (view == null) { view = new View(activity); }/*from w w w . ja v a 2 s . c o m*/ inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
public static void hideSoftKeyborad(Activity context) { if (context == null) return;//from w w w . j av a 2 s.co m ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( context.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static boolean isWifiAvailable(Activity activity) { ConnectivityManager connManager = (ConnectivityManager) activity .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return mWifi.isConnected(); }
From source file:Main.java
/** * Hide soft keyboard//from ww w .j av a 2 s . c o m * @param activity The activity */ public static void hideSoftKeyboard(Activity activity) { final InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); //noinspection ConstantConditions inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }
From source file:Main.java
public static void copy(Activity activity, String tag, String text) { ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(activity.CLIPBOARD_SERVICE); ClipData clip = android.content.ClipData.newPlainText(tag, text); clipboard.setPrimaryClip(clip);//from w w w . j a v a 2 s .co m }
From source file:Main.java
/** * Function to check if a Service is running. * * @param serviceClass The service's class. * @return true if running, else false./*from www .j a v a 2 s . c o m*/ */ private static boolean serviceIsRunning(Class<?> serviceClass, Activity activity) { ActivityManager manager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return true; } } return false; }
From source file:Main.java
public static void showKeyboard(Activity _activity, View _view) { InputMethodManager inputMethodManager = (InputMethodManager) _activity .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.showSoftInput(_view, 0); }
From source file:Main.java
public static void hideSoftKeyboard(Activity activity) { if (null != activity.getCurrentFocus()) { ((InputMethodManager) (activity.getSystemService(Activity.INPUT_METHOD_SERVICE))) .hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }//w w w . j av a2s . co m }
From source file:Main.java
public static void hideKeyBoard(Activity activity) { if (activity.getCurrentFocus() != null) { ((InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*from w w w .j av a 2 s .c om*/ }