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 String getIMSI(Context paramContext) { return ((TelephonyManager) paramContext.getSystemService(Context.TELEPHONY_SERVICE)).getSubscriberId(); }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getHeight(); }
From source file:Main.java
public static boolean checkIsScreenOn(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); return pm.isScreenOn(); }
From source file:Main.java
public static void setCurrentVolume(int percent, Context mc) { AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE); int maxvolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC); am.setStreamVolume(AudioManager.STREAM_MUSIC, (maxvolume * percent) / 100, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); am.setMode(AudioManager.MODE_INVALID); }
From source file:Main.java
public static int getWifiIsEnabled(Context context) { wifiManager = (WifiManager) context.getSystemService("wifi"); if (wifiManager.isWifiEnabled()) { return 0; }//from w w w .j a v a 2 s . c om return -1; }
From source file:Main.java
private static ClipboardManager getClipboard(Context context) { return (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); }
From source file:Main.java
public static void vibrate(Context thisActivity) { Vibrator vibe = (Vibrator) thisActivity.getSystemService(Context.VIBRATOR_SERVICE); //28 ms is the default short android vibrate time length vibe.vibrate(28);/* w w w. ja va 2 s .c om*/ }
From source file:Main.java
private static int getHeapSize(final Context context) { return ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass() * 1024 * 1024;/* w ww .j a va 2s . com*/ }
From source file:Main.java
public static int getScreeHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getHeight(); }
From source file:Main.java
public static int getSreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getWidth(); }