public class PhoneSIMCInfo {
/**手机管理工具类*/
private TelephonyManager telephonyManager;
/**国际移动用户识别码*/
private String mImsi;
public PhoneSIMCInfo(Context context) {
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}
/**获取手机号: 有些手机号无法获取,是因为运营商在SIM中没有写入手机号*/
public String getNativePhoneNumber() {
return telephonyManager.getLine1Number();
}
/**获取手机号码所属公司信息*/
public String getProviderCompanyName() {
String mName = null;
/**获取国际移动用户识别码(IMSI)*/
mImsi = telephonyManager.getSubscriberId();
try
{
mImsi = telephonyManager.getSubscriberId();
if (mImsi.startsWith("46000")) {
mName = "中国移动";
}else if (mImsi.startsWith("46002")) {
mName = "中国移动";
}else if (mImsi.startsWith("46001")) {
mName = "中国联通";
}else if (mImsi.startsWith("46003"))
mName = "中国电信";
}
catch (Exception exception)
{
exception.printStackTrace();
}
return mName;
}
}
-----------附带其它相关信息获取------------------------------
TelephonyManager telephonyManager =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
/**手机串号:GSM手机的 IMEI 和 CDMA手机的 MEID.*/
String deviceID =telephonyManager.getDeviceId();
/**获取手机SIM卡的序列号*/
String imei =telephonyManager.getSimSerialNumber();
/**电话方位*/
CellLocation str =telephonyManager.getCellLocation();
/**取得和语音邮件相关的标签,即为识别符*/
String voiceMail =telephonyManager.getVoiceMailAlphaTag();
/**获取语音邮件号码*/
String voiceMailNumber =telephonyManager.getVoiceMailNumber();
/**获取ISO国家码,相当于提供SIM卡的国家码*/
String simCountryIso =telephonyManager.getSimCountryIso();