Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Mobile no from real device

Tags:

android

I want to get the mobile number of a sim which is inserted into the device. I know as pr the android SDK TelephoneManger is the class by which we can get it by getLine1Number() method. but it always returns null values.

Queries:

  • Can i get mobile number from device?
  • Is it a sim dependent or in some case also device dependent?
  • Any other ways to get the mobile number from device?
like image 355
vivek_Android Avatar asked Feb 11 '11 09:02

vivek_Android


3 Answers

You are using correct and the only approach available to the common user (AFAIK). It is mainly SIM dependent (it is not obligatory to have ), and in some cases may be device dependent (getLine1Number() not correctly implemented).

To be more precise, IMSI uniquely identifies SIM. But MSISDN (the subscriber number) is not uniquely related to SIM, as it is possible to change MSISDN on the SIM. Network may use IMSI from SIM to find MSISDN in the HLR and establish the call.

So, MSISDN is not mandatory to be on the SIM.

like image 84
Zelimir Avatar answered Nov 13 '22 11:11

Zelimir


You should look at this question and its comments.

Some SIM cards seems to cause getLine1Number() to return null... and no one has found a way to deal with this.

More information here

like image 45
Dalmas Avatar answered Nov 13 '22 13:11

Dalmas


In that case you always save your phone no using SharedPreference by using the method getLine1Number() method. when you install your application then your phone number is saven and when when new sim card is used then send SMS to ur registered number. you have to always check after starting the application that your stored number is same with your new number.if same nothing will be happned ,if not same then ur app will send SMS.

like image 35
kowsar Avatar answered Nov 13 '22 11:11

kowsar