我想以编程方式检索设备的移动电话号码。我的代码是: -
TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String strMobileNumber = telephonyManager.getLine1Number();
我在AndroidManifest.xml文件中设置了READ_PHONE_STATE
权限。这是在模拟器上工作,但在eclair版本的实际设备上,它返回空字符串。有没有其他方法让手机没有?
答案 0 :(得分:4)
没有可靠的方法来“以编程方式检索移动设备的数量”,AFAIK。 getLine1Number()
报告SIM卡为GSM手机提供的号码,手机号码不需要在SIM卡上。