问题描述
我试图获取业主contactnumber Android中运行良好的仿真器,但不工作的handset.Here是code
TelephonyManager TM =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
IMEI串= tm.getDeviceId();
串phoneNumber的= tm.getLine1Number();
这不能保证 getLine1Number()
将始终返回在所有设备上的SIM卡的号码。因为数量的可用性取决于其在SIM卡存储。
如果数量没有存储/在SIM卡可用的,则该方法将返回空字符串。
为了让用户的手机号码,你应该送从用户的设备短信到你的服务器或设备(与Viber的或其他应用程序一样)。而对于一个很好的做法,确保它完成与用户的确认。
i am trying to fetch owners contactnumber in android it runs fine in emulator but not working in handset.Here is code
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imei = tm.getDeviceId();
String phoneNumber = tm.getLine1Number();
It is not guaranteed that getLine1Number()
will always return SIM card's number on all devices. Because the availability of number depends on its storage in the SIM card.
If the number is not stored/available in SIM card then the method will return empty string.
In order to get user's phone number, you should send an sms from user's device to your server or device (same as Viber or other app does). And for a good practice make sure it is done with user's acknowledgement.
这篇关于如何获取当前的SIM卡号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!