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 manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static String getWifiName(Context ctx) { WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); Log.d("wifiInfo", wifiInfo.toString()); Log.d("SSID", wifiInfo.getSSID()); return wifiInfo.getSSID(); }
From source file:Main.java
public static DisplayMetrics getScreenMetrics(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(outMetrics); return outMetrics; }
From source file:Main.java
public static Boolean isWiFiEnabled(Context context) { WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifi.isWifiEnabled()) { return true; }/*from w w w .ja v a2 s.c om*/ return false; }
From source file:Main.java
public static String getDeviceID(Context context) { TelephonyManager mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imei = mTm.getDeviceId(); return imei;/*from w w w .ja v a 2 s. c o m*/ }
From source file:Main.java
public static boolean isConnectedToWifi(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean isOpenGPS(Context context) { LocationManager manager = (LocationManager) context.getSystemService(Activity.LOCATION_SERVICE); return manager.isProviderEnabled(LocationManager.GPS_PROVIDER); }
From source file:Main.java
public static String getScreenDisplayID(Context ctx) { WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); return String.valueOf(wm.getDefaultDisplay().getDisplayId()); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getBackgroundDataSetting() && cm.getActiveNetworkInfo() != null; }
From source file:Main.java
public static String getCarrier(Context context) { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return manager.getNetworkOperatorName(); }