在Android中从TelephonyManager检索Line1号码 [英] Retrieving Line1 number from TelephonyManager in Android

查看:76
本文介绍了在Android中从TelephonyManager检索Line1号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TelephonyManager manager1 = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String strMobile1 = manager1.getLine1Number();  

这是我的用于获取手机号码的代码,但无法正常工作.我也在清单文件中获得了必要的权限

This is my code for getting mobile number of but its not working. I have also take necessary permission in manifest file

推荐答案

您使用的方法是SDK唯一执行此操作的部分,并且仅适用于将号码存储在SIM卡上的设备上,只有一些承运人这样做.

The method you are using is the only one part of the SDK to do this, and only works on devices where the number is stored on the SIM card, which only some carriers do.

对于所有其他运营商,您将不得不要求用户手动输入电话号码,因为该号码根本没有存储在设备上您可以从中检索到的任何地方.

For all other carriers, you will have to ask the user to enter the phone number manually, as the number is simply not stored anywhere on the device from where you can retrieve it.

此处来源

这篇关于在Android中从TelephonyManager检索Line1号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆