-1

Can I access the mobile number of a device after installing an app? I can ask from the user for it but need to ensure that it is the correct number that he is inputting. Is there a way? Just need a way to ensure that the app is downloaded on the same mobile number device.

  • In that case, why don't you use UDID of user's device instead of prompting the user. The user may provide wrong number or there may be error in inserting mobile number. – YuDroid Jan 07 '14 at 10:06

1 Answers1

0

Some SIM providers save the number on the SIM. You can directly extract from SIM without user interaction. Use TelephonyManager as follows:

TelephonyManager teleManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String getSimNumber = teleManager.getLine1Number();

Although, it turns out that there might be a case when SIM is present and still you cannot read the number. Some SIM cards doesn't allow to do so while others just don't have the number in the SIM(since this field is not mandatory). Quoting TelephonyManager.getLine1Number() failing?, Android issue about TelephoneManager and this blog, you'll get to know that the presence of number within the SIM isn’t required for operation and is actually assigned directly by the network itself.

Hope this helps.

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124