1

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)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Dave
  • 3,178
  • 5
  • 28
  • 44
  • How can this question be flagged as a duplicate when it was asked almost a year before the other question? – Dave Aug 24 '17 at 17:42

3 Answers3

3

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.

omermuhammed
  • 7,365
  • 4
  • 27
  • 40
  • Thanks omermuhammed, that is a creative solution. It's too bad that it isn't 100% reliable. I am thinking that IMSI might be a better approach for what I need than MSISDN. Seams to be more reliable. – Dave Nov 01 '11 at 17:08
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.

guipivoto
  • 18,327
  • 9
  • 60
  • 75
  • "However, MSISDN is stored in a file in the SIMCard." so my question is, is this number spoofable/modifiable by a malicious user? – Paolo Mar 15 '18 at 15:29
  • In order to write that field in the simcard, you must have the PIN code. Only with that code you will receive write permission.. – guipivoto Mar 15 '18 at 16:55
1

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 :)