Example usage for android.telephony TelephonyManager getSimOperatorName

List of usage examples for android.telephony TelephonyManager getSimOperatorName

Introduction

In this page you can find the example usage for android.telephony TelephonyManager getSimOperatorName.

Prototype

public String getSimOperatorName() 

Source Link

Document

Returns the Service Provider Name (SPN).

Usage

From source file:Main.java

public static String getCarrierName(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm == null ? "" : tm.getSimOperatorName();
}

From source file:Main.java

public static String getSimOperator(Context context) {
    TelephonyManager telephonyManager = ((TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE));
    return telephonyManager.getSimOperatorName();
}

From source file:com.apptentive.android.sdk.storage.DeviceManager.java

private static Device generateNewDevice(Context context) {
    Device device = new Device();

    // First, get all the information we can load from static resources.
    device.setOsName("Android");
    device.setOsVersion(Build.VERSION.RELEASE);
    device.setOsBuild(Build.VERSION.INCREMENTAL);
    device.setOsApiLevel(String.valueOf(Build.VERSION.SDK_INT));
    device.setManufacturer(Build.MANUFACTURER);
    device.setModel(Build.MODEL);/* w  ww . j  a v a  2 s  .  c om*/
    device.setBoard(Build.BOARD);
    device.setProduct(Build.PRODUCT);
    device.setBrand(Build.BRAND);
    device.setCpu(Build.CPU_ABI);
    device.setDevice(Build.DEVICE);
    device.setUuid(GlobalInfo.androidId);
    device.setBuildType(Build.TYPE);
    device.setBuildId(Build.ID);

    // Second, set the stuff that requires querying system services.
    TelephonyManager tm = ((TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE)));
    device.setCarrier(tm.getSimOperatorName());
    device.setCurrentCarrier(tm.getNetworkOperatorName());
    device.setNetworkType(Constants.networkTypeAsString(tm.getNetworkType()));

    // Finally, use reflection to try loading from APIs that are not available on all Android versions.
    device.setBootloaderVersion(Reflection.getBootloaderVersion());
    device.setRadioVersion(Reflection.getRadioVersion());

    device.setLocaleCountryCode(Locale.getDefault().getCountry());
    device.setLocaleLanguageCode(Locale.getDefault().getLanguage());
    device.setLocaleRaw(Locale.getDefault().toString());
    device.setUtcOffset(String.valueOf((TimeZone.getDefault().getRawOffset() / 1000)));
    return device;
}

From source file:hmatalonga.greenhub.models.SimCard.java

/**
 * 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.
 *
 * SIM Operator might or might not own the infrastructure in use.
 * NOTE: Getting multiple operators is highly experimental.
 *
 * @param context Application context/*from   ww w  .j  av  a2  s  . c  o  m*/
 * @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";
}

From source file:Main.java

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;//from   w  w  w.  j av a2s.co m
}

From source file:Main.java

public static String getDeviceInfo(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    StringBuilder sb = new StringBuilder();
    sb.append("\nDeviceId(IMEI) = " + tm.getDeviceId());
    sb.append("\nDeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion());
    sb.append("\nLine1Number = " + tm.getLine1Number());
    sb.append("\nNetworkCountryIso = " + tm.getNetworkCountryIso());
    sb.append("\nNetworkOperator = " + tm.getNetworkOperator());
    sb.append("\nNetworkOperatorName = " + tm.getNetworkOperatorName());
    sb.append("\nNetworkType = " + tm.getNetworkType());
    sb.append("\nPhoneType = " + tm.getPhoneType());
    sb.append("\nSimCountryIso = " + tm.getSimCountryIso());
    sb.append("\nSimOperator = " + tm.getSimOperator());
    sb.append("\nSimOperatorName = " + tm.getSimOperatorName());
    sb.append("\nSimSerialNumber = " + tm.getSimSerialNumber());
    sb.append("\nSimState = " + tm.getSimState());
    sb.append("\nSubscriberId(IMSI) = " + tm.getSubscriberId());
    sb.append("\nVoiceMailNumber = " + tm.getVoiceMailNumber());

    return sb.toString();
}

From source file:com.sxnyodot.uefqvmio207964.Util.java

static String m950f(Context context) {
    if (context == null) {
        return "";
    }/*from ww w .  j a  va 2s . c o  m*/
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
    if (telephonyManager == null || telephonyManager.getSimState() != 5) {
        return "";
    }
    return telephonyManager.getSimOperatorName();
}

From source file:dev.dworks.apps.asecure.MainActivity.java

private void setNewData() {
    TelephonyManager localTelephonyManager = (TelephonyManager) getApplicationContext()
            .getSystemService(Activity.TELEPHONY_SERVICE);
    operatorName = localTelephonyManager.getSimOperatorName();
    simSerial = localTelephonyManager.getSimSerialNumber();
    if (TelephonyManager.SIM_STATE_READY == localTelephonyManager.getSimState()) {
        operator.setText(operatorName);/*www  .  j a va2  s  .  c  o m*/
        number.setText(simSerial);
        simQueryHandler = new SIMQueryHandler(getContentResolver());
        simQueryHandler.startQuery(0, null, SecureSIM.CONTENT_URI, PROJECTION,
                SecureSIMColumns.SIM_NUMBER + " = ? ", new String[] { simSerial }, null);
    } else {
        operator.setText("Unknown");
        number.setText("-");
        register.setImageResource(0);
        register.setOnClickListener(null);
    }
}

From source file:com.wso2.mobile.mdm.api.DeviceInfo.java

/**
*Returns the network operator name/*from ww w  .j  a v a 2s .  c  o m*/
*/
public JSONArray getNetworkOperatorName() {
    JSONArray jsonArray = null;
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (CommonUtilities.DEBUG_MODE_ENABLED) {
        Log.e("Network OP", tm.getSimOperatorName());
    }
    if (tm.getSimOperatorName() != null && tm.getSimOperatorName() != "") {
        networkOperatorName = tm.getSimOperatorName();
    } else {
        networkOperatorName = "No Sim";
    }

    SharedPreferences mainPref = context.getSharedPreferences("com.mdm", Context.MODE_PRIVATE);
    try {
        jsonArray = new JSONArray(mainPref.getString("operators", "[]"));
        boolean simstatus = false;
        if (jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                if ((jsonArray.getString(i) != null)
                        && jsonArray.getString(i).trim().equals(tm.getSimOperatorName())) {
                    simstatus = true;
                }
            }
            if (!simstatus) {
                jsonArray.put(tm.getSimOperatorName());
            }
        } else {
            jsonArray.put(tm.getSimOperatorName());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    Editor editor = mainPref.edit();
    editor.putString("operators", jsonArray.toString());
    editor.commit();

    return jsonArray;
}

From source file:android_network.hetnet.vpn_service.Util.java

public static String getGeneralInfo(Context context) {
    StringBuilder sb = new StringBuilder();
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    sb.append(String.format("Interactive %B\r\n", isInteractive(context)));
    sb.append(String.format("Connected %B\r\n", isConnected(context)));
    sb.append(String.format("WiFi %B\r\n", isWifiActive(context)));
    sb.append(String.format("Metered %B\r\n", isMeteredNetwork(context)));
    sb.append(String.format("Roaming %B\r\n", isRoaming(context)));

    if (tm.getSimState() == TelephonyManager.SIM_STATE_READY)
        sb.append(String.format("SIM %s/%s/%s\r\n", tm.getSimCountryIso(), tm.getSimOperatorName(),
                tm.getSimOperator()));/*from   w  w  w  . j  a va 2  s. co m*/
    if (tm.getNetworkType() != TelephonyManager.NETWORK_TYPE_UNKNOWN)
        sb.append(String.format("Network %s/%s/%s\r\n", tm.getNetworkCountryIso(), tm.getNetworkOperatorName(),
                tm.getNetworkOperator()));

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        sb.append(String.format("Power saving %B\r\n", pm.isPowerSaveMode()));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        sb.append(String.format("Battery optimizing %B\r\n", batteryOptimizing(context)));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        sb.append(String.format("Data saving %B\r\n", dataSaving(context)));

    if (sb.length() > 2)
        sb.setLength(sb.length() - 2);

    return sb.toString();
}