如何使用SIM卡获得Android设备的电话号码或 [英] How to get Phone number of android device using Sim card or

查看:125
本文介绍了如何使用SIM卡获得Android设备的电话号码或的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是在这里,它总是抛出空

My code is here, it is always throwing null

TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String number = tm.getLine1Number();

我使用的许可

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

请给我确切的解决方案,使电话号码。谢谢你。

Please give me exact solution to get phone number. Thank you.

推荐答案

有没有保证的解决这个问题的原因是电话号码没有被物理地存储在所有的SIM卡,或者从网络到电话广播。这是特别真实的,需要的物理地址验证,以编号分配仅发生事后一些国家。电话号码分配发生在网络上 - 并能够在不改变SIM卡或装置(例如,这是移植是如何支持)

There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. Phone number assignment happens on the network - and can be changed without changing the SIM card or device (e.g. this is how porting is supported).

参考:<一href=\"http://stackoverflow.com/questions/2480288/how-can-i-programmatically-obtain-the-number-of-the-android-phone-with-the-api\">How我可以以编程的API获取Android手机的数量?

这篇关于如何使用SIM卡获得Android设备的电话号码或的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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