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
/** * Return the IMEI code// w ww . j av a 2 s .co m * * @param context * @return */ public static String getImeiCode(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getDeviceId(); }
From source file:Main.java
/** * get device id/*w ww . ja v a 2 s . c om*/ * @param context * @return */ public static String getDeviceId(Context context) { TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String deviceId = telManager.getDeviceId(); if (deviceId == null) { deviceId = new String("123456789012345"); } return deviceId; }
From source file:Main.java
private static final boolean mayOnEmulatorViaTelephonyDeviceId(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm == null) { return false; }/*from w w w.j a va 2 s . c o m*/ String deviceId = tm.getDeviceId(); if (TextUtils.isEmpty(deviceId)) { return false; } /** * device id of telephony likes '0*' */ for (int i = 0; i < deviceId.length(); i++) { if (deviceId.charAt(i) != '0') { return false; } } return true; }
From source file:Main.java
public static String getCellularCarrier(Context context) { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String carrierName = manager.getNetworkOperatorName(); if (TextUtils.isEmpty(carrierName)) { carrierName = ""; }/* w w w . j a v a2 s. com*/ return carrierName; }
From source file:Main.java
public static final String getDeviceCode(Context context) { TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telManager != null) { return telManager.getDeviceId(); }/*from w ww. j a va 2 s.com*/ return getLocalMacAddress(context); }
From source file:Main.java
/** * Return the mobile number.//from ww w. j a va 2 s . c o m * * @param context * @return */ public static String getMobileNumber(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getLine1Number(); }
From source file:Main.java
public static String getPhoneNumber(Context context) { try {/*from w ww.jav a 2s . c o m*/ String phone = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)) .getLine1Number(); if (!TextUtils.isEmpty(phone) && phone.startsWith("+86")) { phone = phone.substring(3); } return phone; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static int getMobileNetworkType() { if (mAppContext == null) return -1; TelephonyManager cm = (TelephonyManager) mAppContext.getSystemService(Context.TELEPHONY_SERVICE); if (cm == null) return -1; return cm.getNetworkType(); }
From source file:Main.java
public static String getDeviceIMEI(Context context) { try {// w w w . java 2 s . c o m TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); return telephonyManager.getDeviceId(); } catch (Exception e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static String getDeviceId(Context context) { String deviceId = ""; if (context != null) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (!TextUtils.isEmpty(tm.getDeviceId())) { deviceId = tm.getDeviceId(); }//from www .j a va 2s . c o m } return deviceId; }