手机号不是存在SIM卡上的,SIM卡只有一个串号.
在运营商的服务器上有手机号和序号对应的一张表.所以你SIM卡办理遗失,运营商只要把新SIM卡的串号和你原来的手机号绑定即可.获取手机号的唯一办法是收个短信,短信里面有你的手机号码.所以很多程序为了获取手机号会要求你注册时发短信,然后它给你回个短信.
uses Androidapi . JNI . GraphicsContentViewText, Androidapi . JNIBridge, Androidapi . JNI . Telephony, Androidapi . JNI . JavaTypes, FMX . Helpers . Android; var TelephonyManager: JTelephonyManager; TelephonyServiceNative: JObject; begin TelephonyServiceNative := SharedActivityContext . getSystemService (TJContext . JavaClass . TELEPHONY_SERVICE); if Assigned(TelephonyServiceNative) then TelephonyManager := TJTelephonyManager . Wrap ((TelephonyServiceNative as ILocalObject).GetObjectID); //TelephonyManager.getDeviceId 取IMEI //TelephonyManager.getLine1Number 取MSISDN 手机号,大部分SIM卡中不会写入这个信息 //TelephonyManager.getSimSerialNumber 取ICCID //TelephonyManager.getSubscriberId 取IMSI 运营商实际上是用这个查询的他那张对应电话号码的表 //还有很多方法,具体请查看JTelephonyManager的声明 end ; |
---------------------------------------------------------------------------------------------------------------------
public String readSIMCard() {
TelephonyManager tm = (TelephonyManager)this.getSystemService(TELEPHONY_SERVICE);//取得相关系统服务StringBuffer sb = new StringBuffer();switch(tm.getSimState()){ //getSimState()取得sim的状态 有下面6中状态case TelephonyManager.SIM_STATE_ABSENT :sb.append("无卡");break; case TelephonyManager.SIM_STATE_UNKNOWN :sb.append("未知状态");break;case TelephonyManager.SIM_STATE_NETWORK_LOCKED :sb.append("需要NetworkPIN解锁");break;case TelephonyManager.SIM_STATE_PIN_REQUIRED :sb.append("需要PIN解锁");break;case TelephonyManager.SIM_STATE_PUK_REQUIRED :sb.append("需要PUK解锁");break;case TelephonyManager.SIM_STATE_READY :sb.append("良好");break;}if(tm.getSimSerialNumber()!=null){ sb.append("@" + tm.getSimSerialNumber().toString());}else{ sb.append("@无法取得SIM卡号");}if(tm.getSimOperator().equals("")){ sb.append("@无法取得供货商代码");}else{ sb.append("@" + tm.getSimOperator().toString());}if(tm.getSimOperatorName().equals("")){ sb.append("@无法取得供货商");}else{ sb.append("@" + tm.getSimOperatorName().toString());}if(tm.getSimCountryIso().equals("")){ sb.append("@无法取得国籍");}else{ sb.append("@" + tm.getSimCountryIso().toString());}if (tm.getNetworkOperator().equals("")) { sb.append("@无法取得网络运营商");} else { sb.append("@" + tm.getNetworkOperator());}if (tm.getNetworkOperatorName().equals("")) { sb.append("@无法取得网络运营商名称");} else { sb.append("@" + tm.getNetworkOperatorName());}if (tm.getNetworkType() == 0) { sb.append("@无法取得网络类型");} else { sb.append("@" + tm.getNetworkType());}return sb.toString();}参考:
http://www.360doc.com/content/13/1201/15/9200790_333643872.shtml
http://www.cnblogs.com/-cyb/articles/Android_Read_Sim.html