Android – Retrieve phone number

By -



Hi,

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.

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

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