List of usage examples for android.content Context getSystemService
@SuppressWarnings("unchecked") public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass)
From source file:Main.java
public static final void cancel(Context context, int id) { ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(id); }
From source file:Main.java
public static ConnectivityManager getConnectivityManager(Context context) { return (ConnectivityManager) context.getSystemService(Activity.CONNECTIVITY_SERVICE); }
From source file:Main.java
public static void vibrate(Context context) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(500);//w w w .j a v a 2 s .c o m }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { return ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo() != null; }
From source file:Main.java
public static TelephonyManager getManager(final Context context) { return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); }
From source file:Main.java
private static InputMethodManager getInputMethodManager(Context context) { return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); }
From source file:Main.java
@TargetApi(14) public static int getMemoryRatioForLargeMemoryClass(Context paramContext) { return ((ActivityManager) paramContext.getSystemService("activity")).getLargeMemoryClass(); }
From source file:Main.java
public static float getScreenHight(Context context) { windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return windowManager.getDefaultDisplay().getHeight(); }
From source file:Main.java
public static void show(Context ctx, EditText edit) { ((InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(edit, InputMethodManager.SHOW_FORCED); }
From source file:Main.java
public static Object get(Context context, String key) { Object service = context.getSystemService(key); if (service == null) { service = context.getApplicationContext().getSystemService(key); }/*w w w. j a v a2 s . c o m*/ return service; }