0

I am working in my application and fetching phone number using the method:

TelephonyManager phoneManager = (TelephonyManager)appContext.getSystemService(Context.TELEPHONY_SERVICE);
        number = phoneManager.getLine1Number();

It is working well and good with all the SIM card, but getting problem in Airtel provider SIM card. I am getting blank while trying with this SIM card.

I don't know why Android API is dealing differently with different providers. Please suggest me.

Sam-In-TechValens
  • 2,501
  • 4
  • 34
  • 67

2 Answers2

2

It is because the MSISDN number is not filled on the SIM card by the operator. unfortunately nothing you can do about that.

Thread with some insight on it here

Community
  • 1
  • 1
Ahmed Aeon Axan
  • 2,139
  • 1
  • 17
  • 30
0

You have to use Telephony Manager;If at all you not found the contact no. of user; You can get Sim Serial Number of Sim Card and Imei No. of Android Device by using the same Telephony Manager Class...

Add permission:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

Import:

import android.telephony.TelephonyManager;

Use the below code:

 TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

     // get IMEI
     imei = tm.getDeviceId();

     // get SimSerialNumber
     simSerialNumber = tm.getSimSerialNumber();
Yasar Khan
  • 71
  • 12