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 getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); return width; }
From source file:Main.java
public static View inflate(int layout, ViewGroup root, Context context) { LayoutInflater i = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); return i.inflate(layout, root); }
From source file:Main.java
/** * @param ctx// w w w . j ava 2 s.c om * The {@link context}. * * @return A {@link String} representing the device's MAC address */ public static String getDeviceId(Context ctx) { WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); String wmac = wm.getConnectionInfo().getMacAddress(); return wmac; }
From source file:Main.java
public static String getResolution(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); return display.getWidth() + "*" + display.getHeight(); }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getDisplayMetricsHeight(Context mContext) { WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getHeight(); }
From source file:Main.java
public static List<RunningAppProcessInfo> getRunningProcesses(Context ctx) { ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); return am.getRunningAppProcesses(); }
From source file:Main.java
public static boolean isWifiEnable(Context context) { WifiManager mgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (mgr == null) return false; int state = mgr.getWifiState(); return state == WifiManager.WIFI_STATE_ENABLED || state == WifiManager.WIFI_STATE_ENABLING; }
From source file:Main.java
public static boolean gpsWorkIsAvailable(Context context) { LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); return lm.isProviderEnabled(LocationManager.GPS_PROVIDER); }
From source file:Main.java
public static void wakeLockOn(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (wl == null) wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "CLOCK_ALARM"); wl.acquire();//from www .j a v a 2 s . c o m }
From source file:Main.java
/** * return if screen on/* w w w . j a v a 2 s. c om*/ * @param context * @return */ public static boolean isScreenOn(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); return pm.isScreenOn(); }