Android – Retrieve phone number

By -


How do we fetch phone number to use inside our application?

By using below code we can retrieve the phone number:

TelephonyManager mTelephonyMgr;
mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String mblNumber = mTelephonyMgr.getLine1Number();

Note: Dont forget to add READ_PHONE_STATE permission to be added inside the AndroidManifest.xml file:

<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>

FYI, i have tested this in my Samsung Galaxy 3(Version 2.2 and Vodafone is the Carrier) and Its working fine for me.

Paresh Mayani

Lazy android developer, exploring the horizon of android development since 7 years, currently working as a Technical Lead - Android at Simform Solutions, India. Former Application Architect at KarConnect. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

Loading Facebook Comments ...
Loading Disqus Comments ...