List of usage examples for android.content Context TELEPHONY_SERVICE
String TELEPHONY_SERVICE
To view the source code for android.content Context TELEPHONY_SERVICE.
Click Source Link
From source file:Main.java
public static String getDevId(Context context) { return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); }
From source file:Main.java
public static String getCarrier(Context ctx) { TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); return tm.getNetworkOperatorName().toLowerCase(Locale.getDefault()); }
From source file:Main.java
public static String getCountry(Context ctx) { TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); Locale locale = Locale.getDefault(); return tm.getSimState() == TelephonyManager.SIM_STATE_READY ? tm.getSimCountryIso().toLowerCase(Locale.getDefault()) : locale.getCountry().toLowerCase(locale); }
From source file:Main.java
public static String[] getSimOperatorCodes(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String simOperator = telephonyManager.getSimOperator(); String[] mccmnc = new String[] { null, null }; if (!TextUtils.isEmpty(simOperator)) { mccmnc[0] = simOperator.substring(0, 3); mccmnc[1] = simOperator.substring(3); }/*from www. j a v a 2 s.c om*/ return mccmnc; }
From source file:Main.java
public static String[] getNetworkOperatorCodes(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String simOperator = telephonyManager.getNetworkOperator(); String[] mccmnc = new String[] { null, null }; if (!TextUtils.isEmpty(simOperator)) { mccmnc[0] = simOperator.substring(0, 3); mccmnc[1] = simOperator.substring(3); }//from w w w . j a va 2 s . c om return mccmnc; }
From source file:Main.java
public static String getMNC(Context ctx) { String providersName = ""; TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY) { providersName = telephonyManager.getSimOperator(); providersName = providersName == null ? "" : providersName; }//w w w . j av a 2 s. c o m return providersName; }
From source file:Main.java
public static String getImei(Context context, String imei) { try {//from www .j ava 2 s .c om TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); imei = telephonyManager.getDeviceId(); } catch (Exception e) { } return imei; }
From source file:Main.java
/** * @Thach// w w w.j av a2 s .com * @Description: get and save deviceId into sharePreference * @param context * @return deviceId */ public static String getDeviceId(Context context, String keyPref) { String deviceId = null; if (context != null) { // Get from sharePref first deviceId = onGetPref(context, keyPref); // If this is first time if (deviceId == null) { TelephonyManager telephonyManager; telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); deviceId = telephonyManager.getDeviceId(); // Get deviceId with other method - MAC address if (deviceId == null) { deviceId = initMacAddress(context); } } // save to preference onSavePref(context, keyPref, deviceId); } return deviceId; }
From source file:Main.java
private static String getPhoneNumber(Context context) { String result = null;//from w w w. ja v a 2 s. c om try { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); result = tm.getLine1Number(); } catch (Exception e) { Log.w(LOG_TAG, e); } return result == null ? "" : result; }
From source file:Main.java
private static String getPhoneIMSI(Context context) { String result = null;/*from w ww. j av a 2s.c o m*/ try { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); result = tm.getSubscriberId(); } catch (Exception e) { Log.w(LOG_TAG, e); } return result == null ? "" : result; }