android.telephony.TelephonyManager.getDeviceId()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中android.telephony.TelephonyManager.getDeviceId()方法的一些代码示例,展示了TelephonyManager.getDeviceId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getDeviceId()方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getDeviceId

TelephonyManager.getDeviceId介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();

代码示例来源:origin: stackoverflow.com

TelephonyManager tManager = (TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_SERVICE);
String uid = tManager.getDeviceId();

代码示例来源:origin: stackoverflow.com

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();

代码示例来源:origin: stackoverflow.com

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;
}

代码示例来源:origin: stackoverflow.com

TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String uuid = tManager.getDeviceId();

代码示例来源:origin: stackoverflow.com

TelephonyManager mngr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); 
mngr.getDeviceId();

代码示例来源:origin: stackoverflow.com

final TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);            
String myAndroidDeviceId = mTelephony.getDeviceId();

代码示例来源:origin: stackoverflow.com

TelephonyManager telephonyManager = 
  (TelephonyManager)getSystemService(TELEPHONY_SERVICE);  

String imei = telephonyManager.getDeviceId();

代码示例来源:origin: JessYanCoding/MVPArms

public static String getIMEI(Context context) {
  TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  return tel.getDeviceId();
}

代码示例来源:origin: smuyyh/BookReader

public static String getIMEI(Context context) {
  TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  String IMEI = telephonyManager.getDeviceId();
  return IMEI;
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: JackyAndroid/AndroidTVLauncher

/**
 * @param context
 * @return
 */
public static String getImeiCode(Context context) {
  TelephonyManager tm = (TelephonyManager) context
      .getSystemService(Context.TELEPHONY_SERVICE);
  return tm.getDeviceId();
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

public static String getDeviceId(Context context) {
    try {
      TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
      return tm.getDeviceId();
    } catch (Exception e) {
      return "null";
    }
  }
}

代码示例来源:origin: stackoverflow.com

String ts = Context.TELEPHONY_SERVICE;
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(ts);
String imsi = mTelephonyMgr.getSubscriberId();
String imei = mTelephonyMgr.getDeviceId();

代码示例来源:origin: stackoverflow.com

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
String phone = tm.getLine1Number();

代码示例来源:origin: ACRA/acra

@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());
  }
}

代码示例来源:origin: square/assertj-android

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;
}

代码示例来源:origin: robolectric/robolectric

@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));
}

代码示例来源:origin: robolectric/robolectric

@Test(expected = SecurityException.class)
public void getDeviceId_shouldThrowSecurityExceptionWhenReadPhoneStatePermissionNotGranted()
  throws Exception {
 shadowOf(telephonyManager).setReadPhoneStatePermission(false);
 telephonyManager.getDeviceId();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldGiveDeviceId() {
 String testId = "TESTING123";
 shadowOf(telephonyManager).setDeviceId(testId);
 assertEquals(testId, telephonyManager.getDeviceId());
}

相关文章