List of usage examples for android.app Activity getSystemService
@Override
public Object getSystemService(@ServiceName @NonNull String name)
From source file:Main.java
public static boolean isNetworkAvailable(Activity a) { ConnectivityManager connectivityManager = (ConnectivityManager) a.getSystemService(a.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
/** Show soft keyboard when editText is focused * * @param activity/*from w ww . j a va2s.c o m*/ * @param edit_text */ public static void showSoftKeyboard(Activity activity, EditText edit_text) { imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(edit_text, InputMethodManager.SHOW_IMPLICIT); }
From source file:Main.java
public static boolean isTopActivy(Activity activity) { ActivityManager manager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1); String cmpNameTemp = null;/*from w w w .j a v a 2 s. c om*/ if (null != runningTaskInfos) { cmpNameTemp = (runningTaskInfos.get(0).topActivity).toString(); } return null != cmpNameTemp && cmpNameTemp.equals(activity.getComponentName().toString()); }
From source file:Main.java
/** * Checks whether application has Internet connection. *//*from ww w .jav a2s . co m*/ public static boolean isConnected(Activity a) { ConnectivityManager connMgr = (ConnectivityManager) a.getSystemService(Activity.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) return true; else return false; }
From source file:Main.java
public static void hideSoftInput(Activity activity, View view) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
public static void toggleKeyboard(Activity activity, View v) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); }
From source file:Main.java
public static boolean networkConnected(Activity activity) { ConnectivityManager conManager = (ConnectivityManager) activity .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = conManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); }
From source file:Main.java
public static void showSoftInputMethod(Activity activity, View view) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); }
From source file:Main.java
public static void hideKeyboard(Activity activity, View view) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
public static void showKeyBoard(Activity activity, View view) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); }