1

Possible Duplicate:
Get Phone Number in Android SDK

I am trying to get the phone number in android.

But it is returning null.

Here is my code.

private String getMyPhoneNumber(){
    TelephonyManager mTelephonyMgr;
    mTelephonyMgr = (TelephonyManager)
        getSystemService(Context.TELEPHONY_SERVICE); 
    return mTelephonyMgr.getLine1Number();
}

I have added in my manifest

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

Waiting for your reply and thanks in advance

Community
  • 1
  • 1
Altaf
  • 5,150
  • 10
  • 39
  • 55
  • check this answer: http://stackoverflow.com/a/6797278/379693 – Paresh Mayani Dec 30 '11 at 06:41
  • See: http://stackoverflow.com/questions/2480288/get-phone-number-in-android-sdk It looks similar to what you have done, but note `CommonsWare`'s comment: > Also, there are reports > that some SIMs cause this method to return null. – Brad Dec 30 '11 at 06:40

0 Answers0