Lerchmo
Lerchmo

Reputation: 199

Foolproof way to get Android User's Personal Phone Number?

I currently use this:

TelephonyManager telephonyManager = 
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);

String phoneNumber = telephonyManager.getLine1Number();

Which works like 85% of the time. But on some phones it returns nothing. I believe this is due to differences in Sim cards.

Is there somewhere else on the Android platform to gain this information reliably?

Thanks

Upvotes: 3

Views: 1761

Answers (1)

Robby Pond
Robby Pond

Reputation: 73484

There isn't one. As far as I know, getLineNumber() returns the Number that is shown in the About Phone screen but it doesn't always work. The api for getLineNUmber() even says this, it returns null when the phone number isn't available.

Upvotes: 1

Related Questions