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

The following examples show how to use android.telephony.TelephonyManager#getSimOperatorName() . 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
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 2
Source Project: Android-UtilCode   File: PhoneUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获取手机状态信息
 * <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;
}
 
Example 3
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 4
String toJson(Context context) {
    try {
        appName = context.getString(R.string.app_name);
        systemType = "Android";
        systemVersion = Build.VERSION.RELEASE;
        version = "1.0";
        deviceModel = Build.MODEL;
        deviceName = Build.PRODUCT;

        PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        appVersion = pi.versionName;

        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        operator = telephonyManager.getSimOperatorName();

        connectionType = NetworkStauts.getCurrentNetworkType(context);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    return new Gson().toJson(this);
}
 
Example 5
public static String getMobileOperatorName(Context mContext) {
    String name = "unKnown";
    TelephonyManager telephonyManager = (TelephonyManager) mContext
            .getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY) {
        // IMSI 国际移动用户识别码(IMSI:International Mobile Subscriber
        // Identification
        // Number)是区别移动用户的标志,
        // 储存在SIM卡中,可用于区别移动用户的有效信息。
        // IMSI由MCC、MNC组成,
        // 其中MCC为移动国家号码,由3位数字组成唯一地识别移动客户所属的国家,我国为460;
        // MNC为网络id,由2位数字组成, 用于识别移动客户所归属的移动网络,中国移动为00和02,中国联通为01,中国电信为03
        String imsi = telephonyManager.getNetworkOperator();
        if (imsi.equals("46000") || imsi.equals("46002")) {
            name = "中国移动";
        } else if (imsi.equals("46001")) {
            name = "中国联通";
        } else if (imsi.equals("46003")) {
            name = "中国电信";
        } else {
            // 其他电信运营商直接显示其名称,一般为英文形式
            name = telephonyManager.getSimOperatorName();
        }
    }
    return name;
}
 
Example 6
public static String getSIMCarrierName(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager != null) {
        try {
            return telephonyManager.getSimOperatorName();
        } catch (SecurityException ex) {
            return "unknown";
        }
    }
    return "unknown";
}
 
Example 7
Source Project: batteryhub   File: SimCard.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * SIM Operator is responsible for the product that is subscription.
 * It is directly associated with the SIM card and remains the same
 * even when changing between physical networks.
 * <p>
 * SIM Operator might or might not own the infrastructure in use.
 * NOTE: Getting multiple operators is highly experimental.
 *
 * @param context Application context
 * @return SIM Operator name
 */
public static String getSIMOperator(Context context) {
    TelephonyManager telephonyManager =
            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String operator;

    operator = getSIMOperators(context); // Supports multiple sim cards
    if (operator != null && operator.length() > 0) return operator;
    operator = telephonyManager.getSimOperatorName();
    if (operator != null && operator.length() > 0) return operator;

    return "unknown";
}
 
Example 8
/**
 * 获取系统的其他信息,组成json
 */
public static String getOther(Context context) {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    try {
        sb.append("\"kvn\":\"").append(BuildConfig.VERSION_NAME).append("\"").append(",");
        sb.append("\"kvc\":\"").append(BuildConfig.VERSION_CODE).append("\"").append(",");
        sb.append("\"sid\":\"").append(object2String(Build.ID)).append("\"").append(",");
        sb.append("\"sdv\":\"").append(object2String(Build.DEVICE)).append("\"").append(",");
        sb.append("\"sbr\":\"").append(object2String(Build.BRAND)).append("\"").append(",");
        sb.append("\"smo\":\"").append(object2String(Build.MODEL)).append("\"").append(",");
        sb.append("\"spd\":\"").append(object2String(Build.PRODUCT)).append("\"").append(",");
        sb.append("\"smf\":\"").append(object2String(Build.MANUFACTURER)).append("\"").append(",");
        sb.append("\"shw\":\"").append(object2String(Build.HARDWARE)).append("\"").append(",");
        sb.append("\"sfp\":\"").append(object2String(Build.FINGERPRINT)).append("\"").append(",");
        sb.append("\"stp\":\"").append(object2String(Build.TYPE)).append("\"").append(",");
        sb.append("\"shs\":\"").append(object2String(Build.HOST)).append("\"").append(",");
        sb.append("\"sbd\":\"").append(object2String(Build.BOARD)).append("\"").append(",");
        sb.append("\"stm\":\"").append(object2String(Build.TIME)).append("\"").append(",");
        sb.append("\"sca\":\"").append(object2String(Build.CPU_ABI)).append("\"").append(",");
        sb.append("\"sbl\":\"").append(object2String(Build.BOOTLOADER)).append("\"").append(",");
        sb.append("\"sdp\":\"").append(object2String(Build.DISPLAY)).append("\"").append(",");
        sb.append("\"stg\":\"").append(object2String(Build.TAGS)).append("\"").append(",");
        sb.append("\"svr\":\"").append(object2String(Build.VERSION.RELEASE)).append("\"").append(",");
        sb.append("\"svs\":\"").append(object2String(Build.VERSION.SDK_INT)).append("\"").append(",");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            sb.append("\"svb\":\"").append(object2String(Build.VERSION.BASE_OS)).append("\"").append(",");
        }
        sb.append("\"svc\":\"").append(object2String(Build.VERSION.CODENAME)).append("\"").append(",");
        sb.append("\"svi\":\"").append(object2String(Build.VERSION.INCREMENTAL)).append("\"").append(",");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            sb.append("\"svs\":\"").append(object2String(Build.VERSION.SECURITY_PATCH)).append("\"").append(",");
        }

        if (context != null) {
            TelephonyManager phone = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

            sb.append("\"avc\":\"").append(context.getPackageName()).append("\"").append(",");
            sb.append("\"avn\":\"").append(getVersionName(context)).append("\"").append(",");
            sb.append("\"aan\":\"").append(getAppName(context)).append("\"").append(",");
            if (phone != null) {
                if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
                    @SuppressLint("HardwareIds") String telephone = phone.getSimSerialNumber();
                    if (!TextUtils.isEmpty(telephone)) {
                        sb.append("\"psn\":\"").append(object2String(telephone)).append("\"").append(",");
                    }
                    @SuppressLint("HardwareIds") String subscriberId = phone.getSubscriberId();
                    if (!TextUtils.isEmpty(subscriberId)) {
                        sb.append("\"psi\":\"").append(object2String(subscriberId)).append("\"").append(",");
                    }
                }
                int phoneType = phone.getPhoneType();
                sb.append("\"ppt\":\"").append(object2String(phoneType)).append("\"").append(",");
                String simCountryIso = phone.getSimCountryIso();
                if (!TextUtils.isEmpty(simCountryIso)) {
                    sb.append("\"psc\":\"").append(object2String(simCountryIso)).append("\"").append(",");
                }
                String simOperator = phone.getSimOperator();
                if (!TextUtils.isEmpty(simOperator)) {
                    sb.append("\"pso\":\"").append(object2String(simOperator)).append("\"").append(",");
                }
                String simOperatorName = phone.getSimOperatorName();
                if (!TextUtils.isEmpty(simOperatorName)) {
                    sb.append("\"psn\":\"").append(object2String(simOperatorName)).append("\"").append(",");
                }
            }

            if (context.getResources() != null) {
                DisplayMetrics metrics = context.getResources().getDisplayMetrics();
                if (metrics != null) {
                    sb.append("\"dmd\":\"").append(object2String(metrics.density)).append("\"").append(",");
                    sb.append("\"ddp\":\"").append(object2String(metrics.densityDpi)).append("\"").append(",");
                    sb.append("\"dmx\":\"").append(object2String(metrics.xdpi)).append("\"").append(",");
                    sb.append("\"dmy\":\"").append(object2String(metrics.ydpi)).append("\"").append(",");
                    sb.append("\"dsd\":\"").append(object2String(metrics.scaledDensity)).append("\"").append(",");
                }
            }
        }

        sb = sb.deleteCharAt(sb.length() - 1);
    } catch (Exception ignored) {
    }
    sb.append("}");
    return sb.toString();
}
 
Example 9
Source Project: Android-utils   File: DeviceUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String getSimOperatorName() {
    TelephonyManager tm =
            (TelephonyManager) UtilsApp.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    //noinspection ConstantConditions
    return tm.getSimOperatorName();
}
 
Example 10
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 11
Source Project: Common   File: PhoneUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Return the sim operator name.
 *
 * @return the sim operator name
 */
public static String getSimOperatorName(@NonNull Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
    return tm.getSimOperatorName();
}
 
Example 12
Source Project: Android-UtilCode   File: PhoneUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取Sim卡运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @return sim卡运营商名称
 */
public static String getSimOperatorName() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getSimOperatorName() : null;
}
 
Example 13
Source Project: RxTools-master   File: RxDeviceTool.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取服务商名称
 *
 * @param context
 * @return
 */
public static String getSimOperatorName(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getSimOperatorName();
}
 
Example 14
Source Project: AndroidUtilCode   File: PhoneUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Return the sim operator name.
 *
 * @return the sim operator name
 */
public static String getSimOperatorName() {
    TelephonyManager tm = getTelephonyManager();
    return tm.getSimOperatorName();
}
 
Example 15
Source Project: KeyboardView   File: SystemUtil.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 获取Sim卡运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @param context 上下文
 * @return sim卡运营商名称
 */
public static String getSimOperatorName(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getSimOperatorName() : null;
}