Getting reliable MSISDN from Android Phone? VoiceMailNumber Line1Number

Dave picture Dave · Oct 27, 2011 · Viewed 9.6k times · Source

First off the MSISDN is the same as the phone number. I have been looking into seeing if it if possible to get the phone number off of an Andoid phone.

The result of my research was yes and no.

It is possible using TelephonyManager and getLine1Number(). However this is unreliable.

I have tested the above with a Motorola Atrix and this does not retrieve a valid phone number. So dead in the water right?

Well I was able to get the phone number off the phone using TelephonyManager and getVoiceMailNumber().

I would not have ever guessed that the voicemail number would be my actual phone's number (MSISDN).

So my question is that would checking either getLine1Number() or getVoiceMailNumber() be a reliable way to get MSISDN? (ie: if getLine1Number returns 0000000000000, then check getVoiceMailNumber or something along those lines.)

No one on this website has mentioned before being able to get MSISDN from getVoiceMailNumber() and this is definitely not apparent and almost contradictory to the documentation, but the fact is that it works for my particular device. (untested on other devices)

Answer

omermuhammed picture omermuhammed · Oct 27, 2011

It wont be 100% reliable if you use getVoiceMailNumber(). A lot of times this may give the phone number but what if the handset gets a firmware update and this number changes to something else? say a short code? So no, it is not reliable.

If you can get the number from getLine1Number() then why dont you prompt user to enter the number? You can verify it by sending that number an SMS message with a short code, which the user will be required to enter in the app before proceeding further.