-1

Telephone Manager give me Null phone number while i have use this code -

TelephonyManager tMgr=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
Log.i(TAG, "PH No"+mPhoneNumber);

Permission::

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

it get me null when i have print it....

06-13 12:29:02.749: INFO/Login(5273): PH Nonull

Please help me out this

Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
Nikunj Patel
  • 21,853
  • 23
  • 89
  • 133
  • Possible duplicate of http://stackoverflow.com/questions/2443524/getline1number-return-null-but-not-always http://stackoverflow.com/questions/10619872/the-exact-solution-of-the-get-phone-number-in-android http://stackoverflow.com/questions/5755379/how-to-get-my-phonenumber http://stackoverflow.com/questions/2480288/get-phone-number-in-android-sdk http://stackoverflow.com/questions/3278801/how-to-get-the-telephone-number-in-real-device This question has been asked and answered/discussed numerous times. There is no reliable way to get the user's phone number. Period. End of story. – David Wasser Jun 13 '12 at 07:40

1 Answers1

0

getLine1Number(); returns whatever is stored on the SIM card's MSISDN, which isn't filled by some operators.

In your case i am pretty much sure The MSISDN is unfilled.

You should keep one thing in mind.

getLine1Number() sometimes return with null value or with the phone number originally stored in SIM card.

Vipul
  • 27,808
  • 7
  • 60
  • 75
  • maybe stupid question but do u have sim card in your phone? and make sure it has network – Vipul Jun 13 '12 at 07:22