Getting reliable MSISDN from Android Phone? VoiceM

2019-03-01 11:46发布

问题:

This question already has an answer here:

  • MSISDN : Is it a SIM Card Data? Why all The Provided Function (from Blackberry and Android) to fetch MSISDN not reliable? 3 answers

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)

回答1:

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.



回答2:

This is an old question. However, I would like to share some information which may help people in the future:

getLine1Number() Returns the phone number string for line 1, for example, the MSISDN for a GSM phone. Return null if it is unavailable.

MSISDN is the phone number. However, MSISDN is stored in a file in the SIMCard. Main problem is that it is not mandatory to fill that file. So, you have some simcards which includes MSISDN while other simcards does not have that information.

So, read the MSISDN is totally NOT reliable.

getVoiceMailNumber() Returns the voice mail number. Return null if it is unavailable.

This is also not reliable since this number changes from carrier to carrier. Some carrier uses as voice mail your own phone number. However, some other carriers uses a different number like *55 or something like that.

So, it is very difficult to determine your own phone number. So, avoid to use phone number.



回答3:

another way of going through it is to make the user input their number. then send an SMS to this number entered.

validate that this message has been received, then u can categorically say that the user has entered the correct MSISDN and you store this.

simples :)