0

Possible Duplicate:
Get Phone Number in Android SDK

I want to read my phone number I had tried this:

TelephonyManager manager =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
   phoneNumber = manager.getLine1Number(); 

But it returns null. In my setting->about phone->phone number also it shows unknown.

Then how to read own phone number in android.

Any suggestion will be appreciated,Thanks in advance

Community
  • 1
  • 1
PPD
  • 5,660
  • 12
  • 52
  • 86

2 Answers2

2

You can check this tutorial for How to Get Own Mobile Number Programmatically

Please read all the information I have written below tutorial there

As I have read, so far some people have conflict about different behavior of output. There are reports that some SIMs cause this method to return null.

Because There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards.

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
0

Try after adding the permission READ_PHONE_STATE to the manifest file.

Gridtestmail
  • 1,459
  • 9
  • 10