1. 程式人生 > >Android 獲取手機SIM卡運營商

Android 獲取手機SIM卡運營商

uil track service del 手機 star tor eas on()

直接上代碼:

	/**
	 * 獲取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卡運營商