android中的传入号码SIM卡插槽检测

时间:2018-04-04 10:46:31

标签: android

//SubscriptionManager detection incoming number slot
SubscriptionManager mLocationManager = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
final List<SubscriptionInfo> activeSubscriptionInfoList = mLocationManager.getActiveSubscriptionInfoList();
int simCount = activeSubscriptionInfoList.size();
// btnBack.setText(simCount+" Sim available");
Log.d("MainActivity: ","simCount:" +simCount);

for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
    Log.d("MainActivity: ","iccId :"+ subscriptionInfo.getIccId()+" , name : "+ subscriptionInfo.getDisplayName());
    Toast.makeText(context,"iccId :"+ subscriptionInfo.getIccId()+" , name : "+ subscriptionInfo.getDisplayName(), Toast.LENGTH_LONG).show();
}

SubscriptionManager subMgr = SubscriptionManager.from(context);
SubscriptionInfo sir = subMgr.getActiveSubscriptionInfoForSimSlotIndex(1);
if (sir == null) {

}
SubscriptionInfo sirs = subMgr.getActiveSubscriptionInfoForSimSlotIndex(2);
if (sirs == null) {
    // not sim 1
} else {
    // sim 2
}

0 个答案:

没有答案