# Android获取本机电话号码

**URL:** <https://www.isharkfly.com/t/android/7486>\
**Category:** 程序语言\
**Created:** [November 30, 2012, 2:13pm UTC](https://www.isharkfly.com/t/android/7486 "2012-11-30T14:13:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [November 30, 2012, 2:13pm UTC](https://www.isharkfly.com/t/android/7486/1 "2012-11-30T14:13:02Z")

</div>

如何在Android上获取本机电话号码，目前Android上提供了一个API可以读取早期SIM卡上固化的号码，

private String getPhoneNumber(){  
TelephonyManager mTelephonyMgr;  
mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY\_SERVICE);  
return mTelephonyMgr.getLine1Number();  
}

上面的getPhoneNumber方法返回当前手机的电话号码，同时必须在androidmanifest.xml中加入 android.permission.READ\_PHONE\_STATE 这个权限，但是Android123提示大家上面的方法只能获取很老SIM卡的手机号码，目前主流的获取用户手机号码一般采用用户主动发送短信到SP或接收手机来获取。
