Java Code Examples for android.telephony.TelephonyManager#getNetworkOperatorName()

The following examples show how to use android.telephony.TelephonyManager#getNetworkOperatorName() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static String[] getCarrierInfo(){
	TelephonyManager tm=(TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
	if(Build.VERSION.SDK_INT>=24){
		tm=tm.createForSubscriptionId(SubscriptionManager.getDefaultDataSubscriptionId());
	}
	if(!TextUtils.isEmpty(tm.getNetworkOperatorName())){
		String mnc="", mcc="";
		String carrierID=tm.getNetworkOperator();
		if(carrierID!=null && carrierID.length()>3){
			mcc=carrierID.substring(0, 3);
			mnc=carrierID.substring(3);
		}
		return new String[]{tm.getNetworkOperatorName(), tm.getNetworkCountryIso().toUpperCase(), mcc, mnc};
	}
	return null;
}
 
Example 2
Source Project: Android-utils   File: DeviceUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Return the phone status.
 * <p>Must hold
 * {@code <uses-permission android:name="android.permission.READ_PHONE_STATE" />}</p>
 *
 * @return DeviceId = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中国电信<br>
 * NetworkType = 6<br>
 * PhoneType = 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")
@RequiresPermission(READ_PHONE_STATE)
public static String getPhoneStatus() {
    TelephonyManager tm =
            (TelephonyManager) UtilsApp.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    //noinspection ConstantConditions
    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();
    return str;
}
 
Example 3
Source Project: batteryhub   File: Phone.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Network operator is responsible for the network infrastructure which
 * might be used by many virtual network operators. Network operator
 * is not necessarily bound to the device and might change at any time.
 *
 * @param context Application context
 * @return Network operator name, aka. carrier
 */
public static String getNetworkOperator(Context context) {
    TelephonyManager telephonyManager =
            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String operator;

    operator = getNetworkOperators(context);
    if (operator != null && operator.length() != 0) return operator;
    operator = telephonyManager.getNetworkOperatorName();
    if (operator != null && operator.length() != 0) return operator;
    // CDMA support
    operator = Specifications.getStringFromSystemProperty(
            context,
            "ro.cdma.home.operator.alpha"
    );
    if (operator != null && operator.length() != 0) return operator;

    return "unknown";
}
 
Example 4
Source Project: RxTools-master   File: RxDeviceTool.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获取手机状态信息
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @param context 上下文
 * @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(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 += "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;
}
 
Example 5
public static String[] getCarrierInfo(){
	TelephonyManager tm=(TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
	if(Build.VERSION.SDK_INT>=24){
		tm=tm.createForSubscriptionId(SubscriptionManager.getDefaultDataSubscriptionId());
	}
	if(!TextUtils.isEmpty(tm.getNetworkOperatorName())){
		String mnc="", mcc="";
		String carrierID=tm.getNetworkOperator();
		if(carrierID!=null && carrierID.length()>3){
			mcc=carrierID.substring(0, 3);
			mnc=carrierID.substring(3);
		}
		return new String[]{tm.getNetworkOperatorName(), tm.getNetworkCountryIso().toUpperCase(), mcc, mnc};
	}
	return null;
}
 
Example 6
Source Project: Cangol-appcore   File: DeviceInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取设备运营商
 *
 * @param context
 * @return
 */
public static String getNetworkOperatorName(Context context) {
    String provider = "";
    try {
        final TelephonyManager manager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        provider = manager.getNetworkOperatorName();
    } catch (Exception e) {
        Log.e("getNetworkOperatorName", "" + e.getMessage(), e);
    }
    return provider;
}
 
Example 7
private String getCarrier() {
    try {
        TelephonyManager manager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        return manager.getNetworkOperatorName();
    } catch (Exception e) {
        // Failed to get network operator name from network
        Diagnostics.getLogger().logError("Failed to get carrier", e);
    }
    return null;
}
 
Example 8
Source Project: AndroidUtilCode   File: NetworkUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Return the name of network operate.
 *
 * @return the name of network operate
 */
public static String getNetworkOperatorName() {
    TelephonyManager tm =
            (TelephonyManager) Utils.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) return "";
    return tm.getNetworkOperatorName();
}
 
Example 9
Source Project: DevUtils   File: NetWorkUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取网络运营商名称 - 中国移动、如中国联通、中国电信
 * @return 运营商名称
 */
public static String getNetworkOperatorName() {
    try {
        TelephonyManager telephonyManager = AppUtils.getTelephonyManager();
        return telephonyManager != null ? telephonyManager.getNetworkOperatorName() : null;
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getNetworkOperatorName");
    }
    return null;
}
 
Example 10
Source Project: snowplow-android-tracker   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param context the android context
 * @return a carrier name or null
 */
public static String getCarrier(Context context) {
    TelephonyManager telephonyManager =
            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    if (telephonyManager != null) {
        String carrierName = telephonyManager.getNetworkOperatorName();
        if (!carrierName.equals("")) {
            return carrierName;
        }
    }
    return null;
}
 
Example 11
Source Project: android-perftracking   File: TelephonyUtil.java    License: MIT License 5 votes vote down vote up
/**
 * Returns the network operator name for this device
 * or "wifi" if there is no network name
 *
 * @param context application context
 * @return network operator name
 */
static String getNetwork(Context context) {
  String network = null;

  TelephonyManager tm = telephonyManager(context);
  if (tm != null) {
    network = tm.getNetworkOperatorName();
  }

  if (network == null || "".equals(network)) {
    network = "wifi";
  }

  return network;
}
 
Example 12
Source Project: Ticket-Analysis   File: PhoneUtils.java    License: MIT License 4 votes vote down vote up
/**
 * 获取手机状态信息
 * <p>需添加权限<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 * <p>返回如下
 * <pre>
 * DeviceId(IMEI) = 99000311726612
 * DeviceSoftwareVersion = 00
 * Line1Number =
 * NetworkCountryIso = cn
 * NetworkOperator = 46003
 * NetworkOperatorName = 中国电信
 * NetworkType = 6
 * honeType = 2
 * SimCountryIso = cn
 * SimOperator = 46003
 * SimOperatorName = 中国电信
 * SimSerialNumber = 89860315045710604022
 * SimState = 5
 * SubscriberId(IMSI) = 460030419724900
 * VoiceMailNumber = *86
 * <pre/>
 */
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 += "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;
}
 
Example 13
public static String getCarrierName(TelephonyManager telephonyManager) {
  return telephonyManager.getNetworkOperatorName();
}
 
Example 14
Source Project: CrawlerForReader   File: NetworkUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取网络运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @return 运营商名称
 */
public static String getNetworkOperatorName() {
    TelephonyManager tm =
            (TelephonyManager) Global.getApplication().getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}
 
Example 15
Source Project: BookReader   File: NetworkUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取移动网络运营商名称
 * <p>如中国联通、中国移动、中国电信</p>
 *
 * @param context 上下文
 * @return 移动网络运营商名称
 */
public static String getNetworkOperatorName(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}
 
Example 16
Source Project: base-module   File: LocalNetHelper.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取移动网络运营商名称
 * <p>如中国联通、中国移动、中国电信</p>
 *
 * @param context 上下文
 * @return 移动网络运营商名称
 */
public static String getNetworkOperatorName(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}
 
Example 17
/**
 * 获取网络运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @return 运营商名称
 */
public static String getNetworkOperatorName() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}
 
Example 18
Source Project: RxTools-master   File: RxNetTool.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取移动网络运营商名称
 * <p>如中国联通、中国移动、中国电信</p>
 *
 * @param context 上下文
 * @return 移动网络运营商名称
 */
public static String getNetworkOperatorName(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}
 
Example 19
Source Project: fangzhuishushenqi   File: NetworkUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取移动网络运营商名称
 * <p>如中国联通、中国移动、中国电信</p>
 *
 * @param context 上下文
 * @return 移动网络运营商名称
 */
public static String getNetworkOperatorName(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}
 
Example 20
Source Project: XFrame   File: XNetworkUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取网络运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @return 运营商名称
 */
public static String getNetworkOperatorName() {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}