I have seen all most all posts regarding this issue but could not yet solved .I tried to get it from TelephonyManager.getVoiceMailNumber(),getLine1Number() but it will return as "null".
Please help me to solve it, if any other way to get it.
I have seen all most all posts regarding this issue but could not yet solved .I tried to get it from TelephonyManager.getVoiceMailNumber(),getLine1Number() but it will return as "null".
Please help me to solve it, if any other way to get it.
Add this permission.
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>``
According to the documentation .getLine1Number()
"Returns the phone number string for line 1, for example, the MSISDN for a GSM phone. Return null if it is unavailable. "
Apparently .getLine1Number()
reads this information from SIM card, so if the operator has set the MSISDN field it will return you its value and null if they did not set this field.
In your case probably your SIM card does not have this field populated by operator.
For More Info You can Visit this.
I got this from here.
When reading this quiestion I started to look around for people with the same issue and found this thread. It looks like not all operators/providers send the MSISDN number (Phone number) to your phone (As Segi before me has already pointed out).
If you go to Settings->About->"Phone identity" you might find out if you have a number on the SIM or not. In my case it says 'Unkown'.