我想要得到当前在手机中的SIM卡号码,即车主号码。以及无论是GSM还是CDMA的网络模式。
我在网上搜索,并尝试使用getLine1Number()来执行此操作;但没有给出任何结果
请帮帮忙,我该怎么做呢?
发布于 2011-05-11 19:20:37
要获取您的SIM卡的号码和网络,您可以这样做:
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
if(cm.getActiveNetworkInfo().getTypeName().equals("MOBILE"))
network = "cellnetwork/3G";
else if(cm.getActiveNetworkInfo().getTypeName().equals("WIFI"))
network = "wifi";
else
network ="na";
uphone = tm.getLine1Number();希望对您有帮助:)
我试过了,它对我很管用
发布于 2011-05-11 18:55:45
对于你能做的电话号码,
// Get the phone number from the telephony manager, and display it
TelephonyManager info = (TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = info.getLine1Number();有关网络模式,请参阅TelephonyManager
发布于 2011-05-11 19:01:37
这个问题已经被问了很多次了。
请参阅How to get the mobile number of current sim card in real device?
而且,我必须补充说,获得电话号码取决于运营商是否在SIM卡上提供了电话号码。
https://stackoverflow.com/questions/5962995
复制相似问题