Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get phonenumber programmatically - Android

is it possible to get the phonenumber of each device programmatically? I tried this code:

TelephonyManager manager =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
mPhoneNumber = manager.getLine1Number();

This works fine with some providers. Unfortunately it does not work with each provider. So i am looking for a trick or work around to get the phonenumber of the device. Is there a solution or is it impossible because the number is not stored on the sim card?

like image 912
JavaForAndroid Avatar asked Jun 25 '13 11:06

JavaForAndroid


People also ask

How can I get mobile number details in Android?

On Android the most common path to finding your number is: Settings > About phone/device > Status/phone identity > Network. This slightly differs on Apple devices, where you can follow the path of Settings > Phone > My Number.

Where do you find your phone number on Samsung?

Swipe up or down to view the apps. Touch Settings. Scroll to and touch About phone. Scroll to My phone number, your phone number is displayed.


1 Answers

The method you are using is the only one part of the SDK to do this, and only works on devices where the number is stored on the SIM card, which only some carriers do. For all other carriers, you will have to ask the user to enter the phone number manually, as the number is simply not stored anywhere on the device from where you can retrieve it.

like image 142
Raghav Sood Avatar answered Sep 29 '22 23:09

Raghav Sood