@Test @Config(minSdk = M) public void shouldGivePhoneCount() { shadowOf(telephonyManager).setPhoneCount(42); assertEquals(42, telephonyManager.getPhoneCount()); }
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneCount() == 2) { // Dual sim }
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneCount() == 2) { // Dual sim }
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneCount() == 2) { // Dual sim }
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneCount() == 2) { // Dual sim }
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneCount() == 2) { // Dual sim }
/** * 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; }
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; }
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));
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)); }
out.name("phone_count").value(manager.getPhoneCount());