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 int getHeapMemorySize(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return manager.getMemoryClass() * 1024 * 1024; }
From source file:Main.java
public static void cleanUpClipboard(Context context) { ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData data = ClipData.newPlainText("", ""); cbm.setPrimaryClip(data);// ww w . ja v a 2 s .c o m }
From source file:Main.java
public static boolean isInternetAtiva(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting(); }
From source file:Main.java
public static void visible_keyboard(Context ctx) { InputMethodManager imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static String getImei(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getDeviceId(); }
From source file:Main.java
public static String getWifiAddress(Context c) { WifiManager wifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { return wifiInfo.getMacAddress(); }/*from ww w . j av a 2s . c o m*/ return ""; }
From source file:Main.java
public static int getWindowHeight(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static void cancelAlarm(Context context, PendingIntent pendingIntent) { ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).cancel(pendingIntent); }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getDeviceHeight(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return manager.getDefaultDisplay().getHeight(); }
From source file:Main.java
public static int getWindowWidth(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); return display.getWidth(); }