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 String getIMEI(Context context) { TelephonyManager mgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String deviceId = mgr.getDeviceId(); if (deviceId != null) { return deviceId; }/* www. j a v a 2 s . co m*/ return ""; }
From source file:Main.java
public static boolean isInternetConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }
From source file:Main.java
public static String getIMSI(Context ctx) { TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); return telephonyManager.getSubscriberId(); }
From source file:Main.java
public static String getPhoneDeviceId(Context context) { TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return telManager == null ? null : telManager.getDeviceId(); }
From source file:Main.java
public static boolean isNetworkConnectet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnected(); }
From source file:Main.java
public static boolean isGPSAvailable(Context context) { LocationManager alm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) { return true; } else {//from w w w. j a v a2 s . co m return false; } }
From source file:Main.java
public static void hitKeyboardOpenOrNot(Context context) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive()) { imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); }/* w w w .j a v a 2s .c o m*/ }
From source file:Main.java
public static String getDeviceId(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Log.d("AppUtils", "getDeviceId:" + tm.getDeviceId()); return tm.getDeviceId(); }
From source file:Main.java
public static long getIPAdress(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); long ipAddress = wifiInfo.getIpAddress(); if (ipAddress == 0) ipAddress = 1001;//from ww w .j a v a 2s . c o m return ipAddress; }