how to get phone number using subcriptionmanager..

JunCainJunCain Member ✭✭✭
edited April 11 in Xamarin.Android

I have a phone with dual sim card slot, and want get both numbers, I used SubcriptionMaager but it will return null.

                        SubscriptionManager subscriptionManager = (SubscriptionManager)GetSystemService(Context.TelephonySubscriptionService);
                        IList<SubscriptionInfo> subscriptionInfoList = subscriptionManager.ActiveSubscriptionInfoList;
                        int subId = subscriptionInfoList[0].SubscriptionId; // sim card 1
                        int _subId = subscriptionInfoList[1].SubscriptionId; // sim card 2


  • JarvanJarvan Member, Xamarin Team Xamurai
    edited April 12

    @JunCain Try following code

    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.Build.VERSION_CODES.LollipopMr1)
        SubscriptionManager subscriptionManager1 = (SubscriptionManager)GetSystemService(Context.TelephonySubscriptionService);
        IList<SubscriptionInfo> subsInfoList = subscriptionManager1.ActiveSubscriptionInfoList;
        foreach (SubscriptionInfo subscriptionInfo in subsInfoList)
            string numbers = subscriptionInfo.Number;
            Console.WriteLine("numbers====" + numbers);
Sign In or Register to comment.