在以编程方式使用短信管理器在双卡手机中发送短信之前,如何提示选择SIM卡?



如何通过提示SIM卡选择来查找订阅ID?

SmsManager smsManager = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
smsManager = SmsManager.getSmsManagerForSubscriptionId();
}else{
smsManager = SmsManager.getDefault();
}`

getSmsManagerForSubscriptionId()内需要订阅 ID

您可以subscriptionManagerObj.getActiveSubscriptionInfoList()获取基于模拟老虎机的订阅ID。基于文档

获取当前插入的 SIM 卡的订阅信息。这 记录将按 getSimSlotIndex(( 排序,然后按 getSubscriptionId(( 排序

SmsManager smsManager = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
SubscriptionManager subscriptionManager = (SubscriptionManager)getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
List<SubscriptionInfo> subscriptionInfoList=subscriptionManager.getActiveSubscriptionInfoList();
int subId = subscriptionInfoList.get(0).getSubscriptionId();// change index to 1 if you want to get Subscrption Id for slot 1.
smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
}else{
smsManager = SmsManager.getDefault();
}

相关内容

  • 没有找到相关文章

最新更新