Android 监控手机两张SIM卡

final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
        @SuppressLint("MissingPermission") final List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
        int simCount = activeSubscriptionInfoList.size();
        Log.d("MainActivityAA: ", "simCount:" + simCount);
        for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
     
            int simSlotIndex = subscriptionInfo.getSimSlotIndex();
            Log.d("MainActivityAA: ", "iccId :" + subscriptionInfo.getIccId() + " , name : " + subscriptionInfo.getDisplayName() + "  " + simSlotIndex);
        }
simCount:2
iccId :XXXXXXXXXXXXXXXXXX87 , name : 中国电信  0
iccId :XXXXXXXXXXXXXXXXXX40 , name : China Unicom  1

Debug

{
     id=6, iccId=898611170XXXXXXXXXXX simSlotIndex=0 carrierId=*** displayName=*** carrierName=*** nameSource=1 iconTint=-16746133 mNumber=* dataRoaming=0 iconBitmap=android.graphics.Bitmap@2214d2e mcc *** mnc ***mCountryIso=*** isEmbedded false accessRules null cardString=898611170XXXXXXXXXXX cardId=5 isOpportunistic false mGroupUUID=null mIsGroupDisabled=false profileClass=-1 ehplmns = *** hplmns = *** subscriptionType=0 mGroupOwner=null mSubStatus=1 mNwMode=-1}
{
     id=3, iccId=898601188XXXXXXXXXXX simSlotIndex=1 carrierId=*** displayName=*** carrierName=*** nameSource=1 iconTint=-16746133 mNumber=* dataRoaming=0 iconBitmap=android.graphics.Bitmap@d4610cf mcc *** mnc ***mCountryIso=*** isEmbedded false accessRules null cardString=898601188XXXXXXXXXXX cardId=2 isOpportunistic false mGroupUUID=null mIsGroupDisabled=false profileClass=-1 ehplmns = *** hplmns = *** subscriptionType=0 mGroupOwner=null mSubStatus=1 mNwMode=-1}

你可能感兴趣的:(Android开发,Android2张SIM卡)