-1

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?

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Ramprasad
  • 7,745
  • 20
  • 69
  • 127
  • 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 Answers2

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,777
  • 15
  • 64
  • 104
  • 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
  • 63,688
  • 8
  • 117
  • 146