Wrong way to get Android user's personal phone number?

I am currently using this:

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

String phoneNumber = telephonyManager.getLine1Number();

It works as in 85% of cases. But on some phones it returns nothing. I believe that this is due to differences in SIM cards.

Is there anywhere else on the Android platform to reliably get this information?

thank

+3
source share
1 answer

No. As far as I know, it getLineNumber()returns the number that appears on the About Phone screen, but it does not always work. Api for getLineNumber()even talks about it, it returns null when the phone number is unavailable.

+1
source

All Articles