List of usage examples for android.app Activity getSystemService
@Override
public Object getSystemService(@ServiceName @NonNull String name)
From source file:Main.java
@SuppressWarnings("static-access") public static void hideSoftInput(Activity activity) { InputMethodManager imm = ((InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE)); imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static boolean isNetworkConnected(Activity activity) { ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
static boolean isNetworkAvailable(Activity a) { ConnectivityManager cm = (ConnectivityManager) a.getSystemService(Context.CONNECTIVITY_SERVICE); // test for connection if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isAvailable() && cm.getActiveNetworkInfo().isConnected()) { return true; } else {// ww w . ja v a2s . c om return false; } }
From source file:Main.java
public static void hideSoftKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); }/*w w w . j a v a 2 s .co m*/ }
From source file:Main.java
public static void changeWifiState(Activity activitiy, boolean isOn) { WifiManager wm = (WifiManager) activitiy.getSystemService(Context.WIFI_SERVICE); if (null != wm) { wm.setWifiEnabled(isOn);/* w w w . ja va2 s. c o m*/ } }
From source file:Main.java
public static void hideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null && activity.getWindow().getCurrentFocus() != null) { imm.hideSoftInputFromWindow(activity.getWindow().getCurrentFocus().getWindowToken(), 0); }// w w w. java 2 s .c o m }
From source file:Main.java
public static void hideSoftKeyboard(Activity act, View v) { InputMethodManager imm = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:Main.java
static public void hideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View focus = activity.getCurrentFocus(); if (focus != null) imm.hideSoftInputFromWindow(focus.getWindowToken(), 0); }
From source file:Main.java
public static final void hideSwKeyBoard(View v, Activity activity) { final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:Main.java
public static void showKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); }/*from w w w .j a v a 2 s.c o m*/ }