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

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

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

TelephonyManager.getPhoneCount介绍

暂无

代码示例

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

@Test
@Config(minSdk = M)
public void shouldGivePhoneCount() {
 shadowOf(telephonyManager).setPhoneCount(42);
 assertEquals(42, telephonyManager.getPhoneCount());
}

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

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneCount() == 2) {
  // Dual sim
}

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

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneCount() == 2) {
  // Dual sim
}

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

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneCount() == 2) {
  // Dual sim
}

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

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneCount() == 2) {
  // Dual sim
}

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

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneCount() == 2) {
  // Dual sim
}

代码示例来源:origin: geniusgithub/AndroidDialer

/**
 * Returns the number of phones available.
 * Returns 1 for Single standby mode (Single SIM functionality)
 * Returns 2 for Dual standby mode.(Dual SIM functionality)
 *
 * Returns 1 if the method or telephonyManager is not available.
 *
 * @param telephonyManager The telephony manager instance to use for method calls.
 */
public static int getPhoneCount(@Nullable TelephonyManager telephonyManager) {
  if (telephonyManager == null) {
    return 1;
  }
  if (CompatUtils.isMarshmallowCompatible() || CompatUtils
      .isMethodAvailable(TELEPHONY_MANAGER_CLASS, "getPhoneCount")) {
    return telephonyManager.getPhoneCount();
  }
  return 1;
}

代码示例来源:origin: geniusgithub/AndroidDialer

static boolean handleDeviceIdDisplay(Context context, String input) {
  TelephonyManager telephonyManager =
      (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  if (telephonyManager != null && input.equals(MMI_IMEI_DISPLAY)) {
    int labelResId = (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) ?
        R.string.imei : R.string.meid;
    List<String> deviceIds = new ArrayList<String>();
    if (TelephonyManagerCompat.getPhoneCount(telephonyManager) > 1 &&
        CompatUtils.isMethodAvailable(TelephonyManagerCompat.TELEPHONY_MANAGER_CLASS,
            "getDeviceId", Integer.TYPE)) {
      for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {
        String deviceId = telephonyManager.getDeviceId(slot);
        if (!TextUtils.isEmpty(deviceId)) {
          deviceIds.add(deviceId);
        }
      }
    } else {
      deviceIds.add(telephonyManager.getDeviceId());
    }
    AlertDialog alert = new AlertDialog.Builder(context)
        .setTitle(labelResId)
        .setItems(deviceIds.toArray(new String[deviceIds.size()]), null)
        .setPositiveButton(android.R.string.ok, null)
        .setCancelable(false)
        .show();
    return true;
  }
  return false;
}

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

TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Log.i("OmSai ", "Single or Dula Sim "+manager.getPhoneCount());
Log.i("OmSai ", "Defualt device ID "+manager.getDeviceId());
Log.i("OmSai ", "Single 1 "+manager.getDeviceId(0));
Log.i("OmSai ", "Single 2 "+manager.getDeviceId(1));

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

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
       // Call some material design APIs here
       TelephonyManager manager = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
       Log.i(TAG, "Single or Dula Sim " + manager.getPhoneCount());
       Log.i(TAG, "Default device ID " + manager.getDeviceId());
       Log.i(TAG, "Single 1 " + manager.getDeviceId(0));
       Log.i(TAG, "Single 2 " + manager.getDeviceId(1));
     }

代码示例来源:origin: termux/termux-api

out.name("phone_count").value(manager.getPhoneCount());

相关文章