TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.getDeviceId();
TelephonyManager tManager = (TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_SERVICE); String uid = tManager.getDeviceId();
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.getDeviceId();
public String getUniqueID(){ String myAndroidDeviceId = ""; TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); if (mTelephony.getDeviceId() != null){ myAndroidDeviceId = mTelephony.getDeviceId(); }else{ myAndroidDeviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID); } return myAndroidDeviceId; }
TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String uuid = tManager.getDeviceId();
TelephonyManager mngr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); mngr.getDeviceId();
final TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String myAndroidDeviceId = mTelephony.getDeviceId();
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); String imei = telephonyManager.getDeviceId();
public static String getIMEI(Context context) { TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tel.getDeviceId(); }
public static String getIMEI(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String IMEI = telephonyManager.getDeviceId(); return IMEI; }
String identifier = null; TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) identifier = tm.getDeviceId(); if (identifier == null || identifier .length() == 0) identifier = Secure.getString(context.getContentResolver(),Secure.ANDROID_ID);
/** * @param context * @return */ public static String getImeiCode(Context context) { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); return tm.getDeviceId(); }
public static String getDeviceId(Context context) { try { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getDeviceId(); } catch (Exception e) { return "null"; } } }
String ts = Context.TELEPHONY_SERVICE; TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(ts); String imsi = mTelephonyMgr.getSubscriberId(); String imei = mTelephonyMgr.getDeviceId();
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); // get IMEI String imei = tm.getDeviceId(); String phone = tm.getLine1Number();
@SuppressLint("HardwareIds") @RequiresPermission(Manifest.permission.READ_PHONE_STATE) @Override void collect(@NonNull ReportField reportField, @NonNull Context context, @NonNull CoreConfiguration config, @NonNull ReportBuilder reportBuilder, @NonNull CrashReportData target) throws Exception { target.put(ReportField.DEVICE_ID, SystemServices.getTelephonyManager(context).getDeviceId()); } }
public TelephonyManagerAssert hasDeviceId(String deviceId) { isNotNull(); String actualDeviceId = actual.getDeviceId(); assertThat(actualDeviceId) // .overridingErrorMessage("Expected device ID <%s> but was <%s>.", deviceId, actualDeviceId) // .isEqualTo(deviceId); return this; }
@Test @Config(minSdk = M) public void shouldGiveDeviceIdForSlot() { shadowOf(telephonyManager).setDeviceId(1, "device in slot 1"); shadowOf(telephonyManager).setDeviceId(2, "device in slot 2"); assertEquals("device in slot 1", telephonyManager.getDeviceId(1)); assertEquals("device in slot 2", telephonyManager.getDeviceId(2)); }
@Test(expected = SecurityException.class) public void getDeviceId_shouldThrowSecurityExceptionWhenReadPhoneStatePermissionNotGranted() throws Exception { shadowOf(telephonyManager).setReadPhoneStatePermission(false); telephonyManager.getDeviceId(); }
@Test public void shouldGiveDeviceId() { String testId = "TESTING123"; shadowOf(telephonyManager).setDeviceId(testId); assertEquals(testId, telephonyManager.getDeviceId()); }