如何获得通话记录手机号码SIM卡卡位?

时间:2019-09-21 10:38:43

标签: c# xamarin

我想让手机的通话记录历史记录进来

in xamarin form .in android call histroy which number comes in which sim if mobile have two sim sloat 

1 个答案:

答案 0 :(得分:2)

        int? SIM1 = null;
        int? SIM2 = null;
        string ICCCodeSIM1 = string.Empty;
        string ICCCodeSIM2 = string.Empty;

Android.Content.Context myContext = Android.App.Application.Context;

通话历史记录编号中的

提供有关SubscriptionId,IccId的所有详细信息。我们必须从必须使用SubscriptionManager获取的simcard详细信息中匹配该ID。

        SubscriptionManager subscriptionManager1 = (SubscriptionManager)myContext.GetSystemService(Android.Content.Context.TelephonySubscriptionService);
        IList<SubscriptionInfo> subsInfoList = subscriptionManager1.ActiveSubscriptionInfoList;
        foreach (SubscriptionInfo subscriptionInfo in subsInfoList)
        {
            if (SIM1 == null)
            {
                SIM1 = subscriptionInfo.SubscriptionId;
                ICCCodeSIM1 = subscriptionInfo.IccId;
            }
            else if (SIM2 == null)
            {
                SIM2 = subscriptionInfo.SubscriptionId;
                ICCCodeSIM2 = subscriptionInfo.IccId;
            }
        }