• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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"/>
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!