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 long getTotalMem(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); am.getMemoryInfo(memoryInfo);// www . j a va 2s . c om return memoryInfo.totalMem; }
From source file:Main.java
public static String getIMEI(Context context) { TelephonyManager ts = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return ts.getDeviceId(); }
From source file:Main.java
public static int getSimState(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getSimState(); }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); return metrics.widthPixels; }
From source file:Main.java
public static int getNetworkType(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getNetworkType(); }
From source file:Main.java
public static int getVolumeMax(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); return audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL); }
From source file:Main.java
public static Point getScreenSize(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/* w ww. ja v a 2 s . co m*/ return size; }
From source file:Main.java
public static int getRunningProcess(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> lists = am.getRunningAppProcesses(); return lists.size(); }
From source file:Main.java
public static String getSimSerialNumber(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getSimSerialNumber(); }
From source file:Main.java
public static boolean isTelephonyEnabled(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY; }