本文介绍了如何获得在Android的自有设备的手机号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想中检索设备的手机号码编程。我的code为: -

I want to retreive mobile number of device programatically. My code is:-

TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String strMobileNumber = telephonyManager.getLine1Number();

和我已经设置 READ_PHONE_STATE 许可在AndroidManifest.xml文件。这是工作在仿真器,但在与闪电版本实际的设备,它返回空字符串。是否有任何其他的方式来获得手机号码?

and I have set READ_PHONE_STATE permission in AndroidManifest.xml file. This is working on emulator but on actual device with eclair version, it is returning empty string. Is there any other way to get mobile no?

推荐答案

有没有可靠的方法来retreive手机号码器件编程,AFAIK。 getLine1Number()报告由SIM卡的GSM手机提供的号码,手机号码并不需要是在SIM卡上。

There is no reliable way to "retreive mobile number of device programatically", AFAIK. getLine1Number() reports the number supplied by the SIM card for GSM phones, and the mobile number does not need to be on the SIM card.

这篇关于如何获得在Android的自有设备的手机号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 03:41