• Post Reply Bookmark Topic Watch Topic
  • New Topic

android how to obtain the phone number of the machine through the interface?  RSS feed

 
Regen Mark
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
android how to obtain the phone number of the machine through the interface?
anyone can help me?
 
Mohan Prasath
Ranch Hand
Posts: 38
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of the time the following code would return null or your old SIM number. But it works some times

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

You have to give the following permission in the AndroidManifest <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!