0

i want to know get the number of device by telephoneManager and getLine1Number() ,it is workly well in analog machine,but in real device i donot get,could you tell me why?

in the com.android.internal.telephony inlude getLine1Number() ,how can use the inner class?

pengwang
  • 19,536
  • 34
  • 119
  • 168
  • 2
    possible duplicate of [Get Phone Number in Android SDK](http://stackoverflow.com/questions/2480288/get-phone-number-in-android-sdk) – Pentium10 Jul 19 '10 at 10:28
  • SIM card gives or not access to the number. – Damian Kołakowski Jul 19 '10 at 14:15
  • yes,i used this TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); mPhoneNumber = tMgr.getLine1Number(); but in the real device i donot get the number,may be SIM card not access to the number – pengwang Jul 20 '10 at 01:14

1 Answers1

1

This question has been asked and answered on SO a number of times. The phone number is (possibly) stored on the SIM-card and you can get it with TelephonyManager.getLine1Number() however, it is not reliable. Some SIM cards don't have the phone number on them (in which case you will get null) and if the user changes his phone number without swapping his SIM card then you will get his old phone number.

David Wasser
  • 93,459
  • 16
  • 209
  • 274