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

The following examples show how to use android.telephony.TelephonyManager#getNetworkOperatorName() . 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
Source File: JNIUtilities.java    From Telegram-FOSS with GNU General Public License v2.0 7 votes vote down vote up
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 File: DeviceUtils.java    From Android-utils with 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 File: JNIUtilities.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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 4
Source File: RxDeviceTool.java    From RxTools-master with 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
Source File: Phone.java    From batteryhub with 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 6
Source File: NetWorkUtils.java    From DevUtils with 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 7
Source File: Util.java    From snowplow-android-tracker with 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 8
Source File: NetworkUtils.java    From AndroidUtilCode with 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 File: DeviceInfo.java    From shinny-futures-android with GNU General Public License v3.0 5 votes vote down vote up
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 10
Source File: DeviceInfo.java    From Cangol-appcore with 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 11
Source File: TelephonyUtil.java    From android-perftracking with 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 File: PhoneUtils.java    From Ticket-Analysis with 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
Source File: AptoideUtils.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public static String getCarrierName(TelephonyManager telephonyManager) {
  return telephonyManager.getNetworkOperatorName();
}
 
Example 14
Source File: NetworkUtils.java    From BookReader with 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 15
Source File: LocalNetHelper.java    From base-module with 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 File: NetworkUtils.java    From AndroidModulePattern with Apache License 2.0 2 votes vote down vote up
/**
 * 获取网络运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @return 运营商名称
 */
public static String getNetworkOperatorName() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getNetworkOperatorName() : null;
}
 
Example 17
Source File: NetworkUtils.java    From CrawlerForReader with 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 18
Source File: RxNetTool.java    From RxTools-master with 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 File: NetworkUtils.java    From fangzhuishushenqi with 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 File: XNetworkUtils.java    From XFrame with 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;
}