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 getScreenHeight(Context context) { WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wManager.getDefaultDisplay().getMetrics(metrics); return metrics.heightPixels; }
From source file:Main.java
public static String getIMSI(Context context) { TelephonyManager phone = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imsi = phone.getSubscriberId(); return imsi == null ? "" : imsi; }
From source file:Main.java
public static String getCurrentSSID(Context context) { WifiManager wifiMan = (WifiManager) (context.getSystemService(Context.WIFI_SERVICE)); WifiInfo wifiInfo = wifiMan.getConnectionInfo(); if (wifiInfo != null) return wifiInfo.getSSID(); else//w w w. jav a 2 s . co m return null; }
From source file:Main.java
public static int getWidth(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(outMetrics); return outMetrics.widthPixels; }
From source file:Main.java
public static String getCarrier(Context context) { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return manager.getNetworkOperatorName().toString(); }
From source file:Main.java
public static boolean isAppRunningForeground(Context context) { ActivityManager var1 = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List list = var1.getRunningTasks(1); return context.getPackageName() .equalsIgnoreCase(((ActivityManager.RunningTaskInfo) list.get(0)).baseActivity.getPackageName()); }
From source file:Main.java
public static void toggleSoftKeybord(Context context) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wManager.getDefaultDisplay().getMetrics(metrics); return metrics.widthPixels; }
From source file:Main.java
public static String getWifiMac(Context mContext) { String str;/* ww w . j a v a 2 s. com*/ str = ((WifiManager) mContext.getSystemService(Context.WIFI_SERVICE)).getConnectionInfo().getSSID(); return TextUtils.isEmpty(str) ? "" : str; }
From source file:Main.java
public static LayoutInflater getLayoutInflater(Context context) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); return inflater; }