private TelephonyManager[] mTelephonyManagers;
numPhones = TelephonyManager.getPhoneCount();mTelephonyManagers = new TelephonyManager[numPhones];
String simName = null;
CharSequence[] items = new CharSequence[phoneCount + 1];
mTelephonyManagers[i] = (TelephonyManager) mContext.getSystemService(TelephonyManager
.getServiceName(Context.TELEPHONY_SERVICE, i));
if (mTelephonyManagers[i].hasIccCard() && mTelephonyManagers[i].getSimState() == TelephonyManager.SIM_STATE_READY) {
simName = (mTelephonyManagers[i].getNetworkOperatorName() != null ? mTelephonyManagers[i].getNetworkOperatorName() : "Unknown");
} else {
simName = "SIM " + (i + 1);
}
items[i] = simName;
}
另一种方法
int phoneCount = TelephonyManager.getPhoneCount();
SimManager simManager = SimManager.get(mContext);
if( simManager != null){
final Sim[] sims = simManager.getSims();
for (int i = 0; i < phoneCount; i++) {
Log.d(TAG,"getSelectSim,i = "+ i);
if (sims != null && sims.length > 1 && PhoneFactory.isCardExist(i) && sims[i].getName() != null && (!sims[i].getName().equals(""))) {
mSelectSimEntries[i] = sims[i].getName();
if ((i + 1) == phoneCount)
return;
}
}
}