2

I want get a phone number, but in device I get "" (empty). Any suggest?

This is my code:

    TelephonyManager tMgr = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    String mPhoneNumber = tMgr.getLine1Number();

mPhoneNumber is empty. Manifest has:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
christian russo
  • 565
  • 1
  • 4
  • 10
  • possible duplicate of [Programmatically obtain the phone number of the Android phone](http://stackoverflow.com/questions/2480288/programmatically-obtain-the-phone-number-of-the-android-phone) – LukaCiko Jul 08 '15 at 14:02

2 Answers2

0

Some models return the phone number, some don't. I had the need for getting the phone number and ended up using Twitter's Fabric Digits. Easy to setup and free to use.

55597
  • 2,033
  • 1
  • 21
  • 40
0

That API call is probing your sim card. Some telecom companies don't require the population of the phone number field in order to operate. So if your sim card doesn't have that information your string will be blank each time.

Zack Matthews
  • 409
  • 2
  • 11