How do get the mobile number from an Android application? After installing the application on the mobile, I want to get the mobile number of the phone. Is there any API available in Android?
Asked
Active
Viewed 860 times
-1
-
possible duplicate of [Get Phone Number in Android SDK](http://stackoverflow.com/questions/2480288/get-phone-number-in-android-sdk) – Hans Olsson Aug 20 '11 at 08:16
2 Answers
0
From my experience, this has been the simplest method:
TelephonyManager manager =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = manager.getLine1Number();
And then add this to your AndroidManifest.xml
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Brian
- 7,955
- 16
- 66
- 107
-
I have tried this method. Actually I display that mobile number String in a Alert Box. In Emulator,Mobile Number displayed in Alert box properly.But in Device, only Empty Alert Box Displayed. What is the problem here...please help me... – Ramprasad Aug 20 '11 at 11:08
0
See http://developer.android.com/reference/android/telephony/TelephonyManager.html#getLine1Number%28%29: you will probably need the appropriate permissions to get it.

Femi
- 64,273
- 8
- 118
- 148