當前位置: 首頁>>代碼示例>>Java>>正文


Java TelephonyManager.getNetworkOperator方法代碼示例

本文整理匯總了Java中android.telephony.TelephonyManager.getNetworkOperator方法的典型用法代碼示例。如果您正苦於以下問題:Java TelephonyManager.getNetworkOperator方法的具體用法?Java TelephonyManager.getNetworkOperator怎麽用?Java TelephonyManager.getNetworkOperator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.getNetworkOperator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getApp()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:43,代碼來源:PhoneUtils.java

示例2: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "honeType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:42,代碼來源:PhoneUtils.java

示例3: getPhoneISP

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機網絡運營商類型
 *
 * @param context
 * @return
 */
public static String getPhoneISP(Context context) {
    if (context == null) {
        return "";
    }
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String teleCompany = "";
    String np = manager.getNetworkOperator();

    if (np != null) {
        if (np.equals(CMCC_ISP) || np.equals(CMCC2_ISP)) {
            teleCompany = "中國移動";
        } else if (np.startsWith(CU_ISP)) {
            teleCompany = "中國聯通";
        } else if (np.startsWith(CT_ISP)) {
            teleCompany = "中國電信";
        }
    }
    return teleCompany;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:DeviceUtils.java

示例4: getMccMnc

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getMccMnc(final Context context) {
  final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  final int configMcc = context.getResources().getConfiguration().mcc;
  final int configMnc = context.getResources().getConfiguration().mnc;
  if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
    Log.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getSimOperator()");
    return tm.getSimOperator();
  } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
    Log.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getNetworkOperator()");
    return tm.getNetworkOperator();
  } else if (configMcc != 0 && configMnc != 0) {
    Log.w(TAG, "Choosing MCC+MNC info from current context's Configuration");
    return String.format("%03d%d",
        configMcc,
        configMnc == Configuration.MNC_ZERO ? 0 : configMnc);
  } else {
    return null;
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:20,代碼來源:TelephonyUtil.java

示例5: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:pan2yong22,項目名稱:AndroidUtilCode-master,代碼行數:43,代碼來源:PhoneUtils.java

示例6: getPhoneStatus

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取手機狀態信息
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中國電信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中國電信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:43,代碼來源:PhoneManager.java

示例7: b

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String b(Context context) {
    String str = "";
    try {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        if (telephonyManager == null) {
            return str;
        }
        String networkOperator = telephonyManager.getNetworkOperator();
        if (networkOperator == null || networkOperator.length() < 3) {
            networkOperator = str;
        } else {
            networkOperator = networkOperator.substring(0, 3);
        }
        return networkOperator;
    } catch (Throwable th) {
        th.printStackTrace();
        return str;
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:e.java

示例8: getOperatorNameCode

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * 獲取網絡運營商並且轉換為有米原生廣告請求協議中的網絡運營商標識號
 *
 * @param context 上下文,會自動去ApplicationContext
 *
 * @return <ul>
 * <li>空:無</li>
 * <li>0: 未知/其他</li>
 * <li>2: 中國移動</li>
 * <li>3: 中國聯通</li>
 * <li>4: 中國電信</li>
 * </ul>
 */
public static String getOperatorNameCode(Context context) {
	try {
		TelephonyManager telephonyManager =
				(TelephonyManager) context.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
		if (telephonyManager != null) {
			String operatorName = telephonyManager.getNetworkOperator();
			if (!TextUtils.isEmpty(operatorName)) {
				if (operatorName.equals("46000") || operatorName.equals("46002") || operatorName.equals("46007")) {
					return "2";
				}
				if (operatorName.equals("46001") || operatorName.equals("46006")) {
					return "3";
				}
				if (operatorName.equals("46003") || operatorName.equals("46005")) {
					return "4";
				}
				return "0";
			}
		}
	} catch (Throwable e) {
		DLog.e(e);
	}
	return "";
}
 
開發者ID:youmi,項目名稱:nativead,代碼行數:38,代碼來源:DeviceInfoUtils.java

示例9: getMCC

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
private String getMCC() {
	TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
	// 返回當前手機注冊的網絡運營商所在國家的MCC+MNC. 如果沒注冊到網絡就為空.
	String networkOperator = tm.getNetworkOperator();
	if (!TextUtils.isEmpty(networkOperator)) {
		return networkOperator;
	}

	// 返回SIM卡運營商所在國家的MCC+MNC. 5位或6位. 如果沒有SIM卡返回空
	return tm.getSimOperator();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:RegisterPage.java

示例10: getNetworkOperator

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getNetworkOperator(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        return "";
    }
    return tm.getNetworkOperator();
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:8,代碼來源:PhoneMessage.java

示例11: getNetworkOperator

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
/**
 * Returns the MCC+MNC (mobile country code + mobile network code) as
 * the numeric name of the current registered operator.
 */
@CalledByNative
private static String getNetworkOperator(Context context) {
    TelephonyManager telephonyManager =
            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null) return "";
    return telephonyManager.getNetworkOperator();
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:12,代碼來源:AndroidNetworkLibrary.java

示例12: getCountryCode

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
@ReactMethod
public void getCountryCode(Promise promise){
  String isoCountryCode="";
  String mobileCountryCode="";
  String mobileNetworkCode="";
  int callPrefix;

  TelephonyManager manager = (TelephonyManager) this.reactContext.getSystemService(Context.TELEPHONY_SERVICE);
  isoCountryCode = manager.getSimCountryIso();
  
  WritableMap map = Arguments.createMap();
  map.putString("isoCountryCode", isoCountryCode);
  
  mobileCountryCode = manager.getNetworkCountryIso();
  map.putString("mobileCountryCode", mobileCountryCode);

  mobileNetworkCode = manager.getNetworkOperator();
  map.putString("mobileNetworkCode", mobileNetworkCode);

  if(isoCountryCode.length() > 0){
    int index = Arrays.asList(isoCodes).indexOf(isoCountryCode.toUpperCase());
    callPrefix = prefixes[index];
    map.putInt("callPrefix", callPrefix);
  }else{
    map.putString("callPrefix", null);
  }
  promise.resolve(map);
}
 
開發者ID:motius,項目名稱:react-native-telephony-apis,代碼行數:29,代碼來源:RNReactNativeTelephonyModule.java

示例13: getNetworkOperator

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getNetworkOperator(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm != null) {
        return tm.getNetworkOperator();
    }
    return null;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:8,代碼來源:NetworkUtil.java

示例14: getNetworkOperator

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getNetworkOperator(Context context) {
	TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
	if(tm != null){
		return tm.getNetworkOperator();
	}
	return null;
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:8,代碼來源:NetworkUtil.java

示例15: downloadBtsDataIfApiKeyAvailable

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
private void downloadBtsDataIfApiKeyAvailable() {
    if (CellTracker.OCID_API_KEY != null && !CellTracker.OCID_API_KEY.equals("NA")) {

        Cell cell = new Cell();
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String networkOperator = tm.getNetworkOperator();

        if (networkOperator != null && !networkOperator.isEmpty()) {
            int mcc = Integer.parseInt(networkOperator.substring(0, 3));
            cell.setMCC(mcc);
            int mnc = Integer.parseInt(networkOperator.substring(3));
            cell.setMNC(mnc);
           Log.d(TAG, mTAG + "CELL:: mcc=" + mcc + " mnc=" + mnc);
        }


        GeoLocation loc = mAimsicdService.lastKnownLocation();
        if (loc != null) {
            Helpers.msgLong(this, getString(R.string.contacting_opencellid_for_data));

            cell.setLon(loc.getLongitudeInDegrees());
            cell.setLat(loc.getLatitudeInDegrees());
            Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST, mAimsicdService);
        } else {
            Helpers.msgShort(this, getString(R.string.waiting_for_location));

            // This uses the LocationServices to get CID/LAC/MNC/MCC to be used
            // for grabbing the BTS data from OCID, via their API.
            // CID Location Async Output Delegate Interface Implementation
            LocationServices.LocationAsync locationAsync
                    = new LocationServices.LocationAsync();
            locationAsync.delegate = this;
            locationAsync.execute(
                    mAimsicdService.getCell().getCID(),
                    mAimsicdService.getCell().getLAC(),
                    mAimsicdService.getCell().getMNC(),
                    mAimsicdService.getCell().getMCC());
        }
    } else {
        Helpers.sendMsg(this, getString(R.string.no_opencellid_key_detected));
    }
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:43,代碼來源:MainActivity.java


注:本文中的android.telephony.TelephonyManager.getNetworkOperator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。