首页 > 移动平台 > 详细

Android 获取手机SIM卡运营商

时间:2017-07-08 09:24:03      阅读:344      评论:0      收藏:0      [点我收藏+]

直接上代码:

	/**
	 * 获取SIM卡运营商
	 * 
	 * @param context
	 * @return
	 */
	public static String getOperators(Context context) {
		TelephonyManager tm = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);
		String operator = null;
		String IMSI = tm.getSubscriberId();
		if (IMSI == null || IMSI.equals("")) {
			return operator;
		}
		if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) {
			operator = "中国移动";
		} else if (IMSI.startsWith("46001")) {
			operator = "中国联通";
		} else if (IMSI.startsWith("46003")) {
			operator = "中国电信";
		}
		return operator;
	}

	/**
	 * 手机型号
	 * 
	 * @return
	 */
	public static String getPhoneModel() {
		return android.os.Build.MODEL;
	}

	/**
	 * 系统版本号
	 * 
	 * @return
	 */
	public static String getSystemVersion() {
		return android.os.Build.VERSION.RELEASE;
	}
权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>



Android 获取手机SIM卡运营商

原文:http://www.cnblogs.com/wzzkaifa/p/7135655.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!