找回电话号码的最佳方法?
我需要能够获取SIM卡的电话号码,目前我一直在使用:
telephonyManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
tmPhone = telephonyManager.getLine1Number();
但此方法并不总是返回结果/正确的结果。
有没有办法 100% 获得正确的电话号码,而不要求用户手动输入?
i need to be able to get the SIM's phone number, currently i have been using:
telephonyManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
tmPhone = telephonyManager.getLine1Number();
but this method doesnt always return a result/the correct result.
is there anyway of getting the correct phone number 100% of the time, without asking the user to manually enter it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用这个。
但它在非电话设备等设备上并不总是可靠。您还需要添加权限“android.permission.READ_PHONE_STATE”。
Use This.
but it's not always reliable on for example non phone device. You will also need to add permission "android.permission.READ_PHONE_STATE".