Example usage for android.telephony TelephonyManager getNetworkOperatorName

List of usage examples for android.telephony TelephonyManager getNetworkOperatorName

Introduction

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

Prototype

public String getNetworkOperatorName() 

Source Link

Document

Returns the alphabetic name of current registered operator.

Usage

From source file:Main.java

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

From source file:Main.java

public static String getCellularCarrier(Context context) {
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String carrierName = manager.getNetworkOperatorName();
    if (TextUtils.isEmpty(carrierName)) {
        carrierName = "";
    }/*w  w w  . jav  a  2  s .co  m*/

    return carrierName;
}

From source file:Main.java

public static boolean isRunningOnEmulator(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String networkOperator = tm.getNetworkOperatorName();

    Log.v(TAG, "Network operator is " + networkOperator);

    if (networkOperator.equals("Android")) {
        Log.i(TAG, "Running on emulator.");
        return true;
    }//w w w  .  j  a v  a2  s  .c o  m

    Log.i(TAG, "Running on real device.");
    return false;
}

From source file:Main.java

public static Map<String, String> getNetworkInfo(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    Map<String, String> map = new HashMap();
    NetworkInfo info = cm.getActiveNetworkInfo();
    if ((info == null) || (!info.isConnectedOrConnecting()) || (withinInBlackList())) {
        map.put("access_subtype", "offline");
        map.put("access", "offline");
        map.put("carrier", "");
    } else {//from  www  . jav a  2 s.  c o  m
        map.put("access_subtype", info.getSubtypeName());
        map.put("access", cleanNetworkTypeName(info.getTypeName()));
        TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        String carrierName = manager.getNetworkOperatorName();
        map.put("carrier", carrierName);
    }
    return map;
}

From source file:alaindc.crowdroid.RadioUtils.java

public static String[] getTelInfo(Context context) {
    TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    String netType = getNetClass(context);
    String operatorName = mTelephonyManager.getNetworkOperatorName();

    SharedPreferences sharedPref = context.getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE);
    String signalStrength = sharedPref.getString(Constants.PREF_SENSOR_ + Constants.TYPE_TEL, "0");
    String throughput = String.valueOf(sharedPref.getFloat(Constants.THROUGHPUT_VALUE, 0));

    return new String[] { netType, signalStrength, operatorName, throughput };
}

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 w  w . jav  a  2  s. c o  m*/
    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:io.lqd.sdk.model.LQDevice.java

private static String getCarrier(Context context) {
    TelephonyManager telephonyManager = ((TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE));
    return telephonyManager.getNetworkOperatorName();
}

From source file:count.ly.messaging.DeviceInfo.java

/**
 * Returns the display name of the current network operator from the
 * TelephonyManager from the specified context.
 * @param context context to use to retrieve the TelephonyManager from
 * @return the display name of the current network operator, or the empty
 *         string if it cannot be accessed or determined
 *//*  ww w  .  j a v a2 s . c o m*/
static String getCarrier(final Context context) {
    String carrier = "";
    final TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (manager != null) {
        carrier = manager.getNetworkOperatorName();
    }
    if (carrier == null || carrier.length() == 0) {
        carrier = "";
        if (Countly.sharedInstance().isLoggingEnabled()) {
            Log.i(Countly.TAG, "No carrier found");
        }
    }
    return carrier;
}

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   ww w. ja va  2 s.  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();
}