android 获得手机运营商

原创
2013/11/04 11:58
阅读数 864
private final static int CMCC = 46000;
private final static int ChinaTelecom = 46003;
private final static int ChinaUnicom = 46001;
private final static int DSF = 0;

public static int getOperator(boolean bEnableCMCC,boolean bEnableChinaTelecom,boolean bEnableChinaUnicom,int defaultSP) {

int CMCC2 = 46002;
int CMCC3 = 46007;
int ChinaUnicom2 = 46006;

TelephonyManager tm = (TelephonyManager)instance.getSystemService(Context.TELEPHONY_SERVICE);

String sp = tm.getSimOperator();
int operator =  Integer.parseInt("".equals(sp)?"0":sp);

if(operator==CMCC||operator==CMCC2||operator==CMCC3)
{
	return bEnableCMCC?CMCC:defaultSP;
}
else if(operator==ChinaTelecom)
{
	return bEnableChinaTelecom?ChinaTelecom:defaultSP;
}
else if(operator==ChinaUnicom||operator==ChinaUnicom2)
{
	return bEnableChinaUnicom?ChinaUnicom:defaultSP;
}
return defaultSP;

}

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部