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 void setWifiEnabled(Context context, boolean enabled) { ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).setWifiEnabled(enabled); }
From source file:Main.java
public static String getDeviceId(Context mContext) { TelephonyManager tm = (TelephonyManager) (mContext.getSystemService(Context.TELEPHONY_SERVICE)); String deviceId = tm.getDeviceId(); return deviceId; }
From source file:Main.java
public static String getIMSI(Context context) { TelephonyManager manager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); return manager.getSubscriberId(); }
From source file:Main.java
public static String getPhoneNumber(Context context) { TelephonyManager teleMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return teleMgr.getLine1Number(); }
From source file:Main.java
public static String getNetWorkOperator(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) { return tm.getNetworkOperator(); }//from w w w . ja v a 2 s. com return ""; }
From source file:Main.java
public static boolean isSIMPresent(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT) { return false; } else//w ww . j a v a2s . c o m return true; }
From source file:Main.java
public static String getWifiName(Context mContext) { String str;// w w w .j ava 2 s. co m str = ((WifiManager) mContext.getSystemService(Context.WIFI_SERVICE)).getConnectionInfo().getBSSID(); return TextUtils.isEmpty(str) ? "" : str; }
From source file:Main.java
public static void hideInput(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 String getLinePhone(Context context) { TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return phoneMgr.getLine1Number(); }
From source file:Main.java
public static boolean isGpsEnabled(Context context) { LocationManager alm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (!alm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { return false; }//from ww w . j a v a2s . c om return true; }