Monday, March 7, 2011

Android Telephony How to get my telephone number?

By Magesh Kumar   Posted at  4:58 AM   Android No comments


Gets the phone number the app is running on. It needs a permission so add the line uses-permission android:name="android.permission.READ_PHONE_STATE" to the manifest.xml 
 private String getMyPhoneNumber(){
   TelephonyManager mTelephonyMgr;
   mTelephonyMgr = (TelephonyManager)
    getSystemService(Context.TELEPHONY_SERVICE);
   return mTelephonyMgr.getLine1Number();
 }

 private String getMy10DigitPhoneNumber(){
  String s = getMyPhoneNumber();
  return s.substring(2);
 }

About the Author

Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9

0 comments:

Back to top ↑
Connect with Us

What they says

© 2013 MaGeSH 2 help. WP Mythemeshop Converted by BloggerTheme9
Blogger templates. Proudly Powered by Blogger.