1

Suppose my phone no is 9-112-345-678, I try given code

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

but its not giving any output when i install same application in samsung fit 2.2.1 O.S.

I also gave necessary permission

uses-permission android:name="android.permission.READ_PHONE_STATE"
Alex K.
  • 171,639
  • 30
  • 264
  • 288
Freni
  • 151
  • 1
  • 3
  • 17

1 Answers1

1

It depends on SIM card. If your SIM card contains it, then getLine1Number would return you, otherwise its empty. You can verify this by going into:

Settings->About Phone->Status->My phone number

On the other hand, take any old nokia/sony-ericsson phone, put your sim in it, and browse to an option to Insert/Edit your sim number. I know, i had to do this to fix this issue with my phone number.

waqaslam
  • 67,549
  • 16
  • 165
  • 178
  • BUt i want to do this thing in newer version phones so can u provide any suggessions for that – Freni Apr 16 '12 at 11:26
  • At the moment, if your SIM card doesn't have its number stored in it, then you are out of luck. Though Android is considering this (change sim number) feature to add, but don't know when or in which release it will be provided – waqaslam Apr 16 '12 at 11:30
  • alternatively, borrow an iPhone, insert your sim, and browse to the option to alter your sim-number – waqaslam Apr 16 '12 at 11:31