0

My android application needs to retrieve the phone number of the device. I'm using the method getLine1Number() to retrieve it, however on some phones it returns a wrong value.

Code:

TelephonyManager tMgr = (TelephonyManager)c.getSystemService(Context.TELEPHONY_SERVICE); String number = tMgr.getLine1Number(); 

The phone returning a wrong value is a Samsung Galaxy S6 running android 6.0.1. In the phone settings under Phone number it displays the same wrong value, however under MIN the correct phone number is displayed.

Can anyone give me any ideas or solutions to this problem? I haven't been able to find any way of retrieving the MIN value from an android phone. Nor have I identified why this phone returns a wrong value.

1
  • Show the application code, we don't know what you're doing. Commented Mar 21, 2016 at 17:32

1 Answer 1

1

There is no function to get the phone number of a device. Because of the ways some carriers set up SIMs, its actually possible that the device itself doesn't know what its own phone number is. If you actually need a phone number, you need to ask the user for it. If you need a unique id for the phone, other things like ANDROID_ID are more appropriate (remember not ever android device even has a phone number- tablets, watched, and TVs may not).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, guess i'll have to find an alternative

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.