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

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

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

TelephonyManager.getMeid介绍

暂无

代码示例

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

@Test
@Config(minSdk = O)
public void getMeid() {
 String testMeid = "4test meid";
 shadowOf(telephonyManager).setMeid(testMeid);
 assertEquals(testMeid, telephonyManager.getMeid());
}

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

@Test
@Config(minSdk = O)
public void getMeidForSlot() {
 shadowOf(telephonyManager).setMeid("defaultMeid");
 shadowOf(telephonyManager).setMeid(0, "meid0");
 shadowOf(telephonyManager).setMeid(1, "meid1");
 assertEquals("meid0", telephonyManager.getMeid(0));
 assertEquals("meid1", telephonyManager.getMeid(1));
}

代码示例来源:origin: oasisfeng/condom

@Test @SuppressLint("HardwareIds") public void testNullDeviceIdKit() throws NameNotFoundException {
  final CondomContext condom = CondomContext.wrap(new ContextWrapper(context), "NullDeviceId",
      new CondomOptions().addKit(new NullDeviceIdKit()));
  final TelephonyManager tm = (TelephonyManager) condom.getSystemService(Context.TELEPHONY_SERVICE);
  assertNotNull(tm);
  assertTrue(tm.getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
  final TelephonyManager app_tm = (TelephonyManager) condom.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
  assertNotNull(app_tm);
  assertTrue(app_tm.getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
  assertPermission(condom, READ_PHONE_STATE, true);
  assertNull(tm.getDeviceId());
  if (SDK_INT >= LOLLIPOP) {
    if (SDK_INT >= M) assertNull(tm.getDeviceId(0));
    assertNull(tm.getImei());
    assertNull(tm.getImei(0));
    if (SDK_INT >= O) assertNull(tm.getMeid());
    if (SDK_INT >= O) assertNull(tm.getMeid(0));
  }
  assertNull(tm.getSimSerialNumber());
  assertNull(tm.getLine1Number());
  assertNull(tm.getSubscriberId());
}

代码示例来源:origin: Trumeet/MiPushFramework

@Test @SuppressLint("HardwareIds") public void testNullDeviceIdKit() {
  final CondomContext condom = CondomContext.wrap(new ContextWrapper(context), "NullDeviceId",
      new CondomOptions().addKit(new NullDeviceIdKit()));
  final TelephonyManager tm = (TelephonyManager) condom.getSystemService(Context.TELEPHONY_SERVICE);
  assertTrue(condom.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE).getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
  assertPermission(condom, READ_PHONE_STATE, true);
  assertNull(tm.getDeviceId());
  if (SDK_INT >= M) assertNull(tm.getDeviceId(0));
  assertNull(tm.getImei());
  assertNull(tm.getImei(0));
  if (SDK_INT >= O) assertNull(tm.getMeid());
  if (SDK_INT >= O) assertNull(tm.getMeid(0));
  assertNull(tm.getSimSerialNumber());
  assertNull(tm.getLine1Number());
  assertNull(tm.getSubscriberId());
}

代码示例来源:origin: adjust/android_sdk

private static String getMeidByIndex(TelephonyManager telephonyManager, int index, ILogger logger) {
  try {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      return telephonyManager.getMeid(index);
    }
  } catch (SecurityException e) {
    logger.debug("Couldn't read MEID in position %d: %s", index, e.getMessage());
  }
  return null;
}

代码示例来源:origin: adjust/android_sdk

private static String getDefaultMeid(TelephonyManager telephonyManager, ILogger logger) {
  try {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      return telephonyManager.getMeid();
    }
  } catch (SecurityException e) {
    logger.debug("Couldn't read default MEID: %s", e.getMessage());
  }
  return null;
}

代码示例来源:origin: linqssonny/Utils

/**
 * Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available.
 *
 * @param context
 * @return
 */
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public static String getMeid(Context context) {
  TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  if (null == telephonyManager) {
    return null;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    return telephonyManager.getMeid();
  } else {
    return telephonyManager.getDeviceId();
  }
}

相关文章