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

/**
 * Get unique device info./*  w w w .ja  v a 2s .c  o m*/
 *
 * @param context application context.
 * @return returns a json object of the device, manufacturer, build version, and a unique id.
 */
public static JSONObject getDeviceInfo(Context context) {
    JSONObject deviceInfo = new JSONObject();
    try {
        deviceInfo.put("device", Build.MODEL);
        deviceInfo.put("manufacturer", Build.MANUFACTURER);
        deviceInfo.put("android", android.os.Build.VERSION.SDK);

        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        String tmDevice = tm.getDeviceId();
        String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
        String serial = null;
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO)
            serial = Build.SERIAL;
        if (androidId != null)
            deviceInfo.put("uid", androidId);
        else if (serial != null)
            deviceInfo.put("uid", serial);
        else if (tmDevice != null)
            deviceInfo.put("uid", tmDevice);
        deviceInfo.put("carrier", tm.getNetworkOperatorName());
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return deviceInfo;
}

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

static String m953g(Context context) {
    if (context == null) {
        return "";
    }// w  w w  .jav  a 2s .com
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
    if (telephonyManager == null || telephonyManager.getPhoneType() != 1) {
        return "";
    }
    return telephonyManager.getNetworkOperatorName();
}

From source file:org.digitalcampus.oppia.utils.MetaDataUtils.java

public MetaDataUtils(Context ctx) {
    this.ctx = ctx;
    TelephonyManager manager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    networkProvider = manager.getNetworkOperatorName();
    deviceId = manager.getDeviceId();/*from   w w  w  . ja v a2 s .c om*/
    simSerial = manager.getSimSerialNumber();
}

From source file:com.tvs.signaltracker.SeeMap.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.seemap);/* w w  w. j  ava2  s .co  m*/
    TelephonyManager Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    CommonHandler.Operator = Utils.DoOperator(Tel.getNetworkOperatorName());
    Log.i("SignalTracker::SeeMap", "Operator: " + CommonHandler.Operator);
    setUpMap();
}

From source file:com.swisscom.safeconnect.fragment.InfoFragment.java

private String getCarrierName() {
    TelephonyManager manager = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
    String carrierName = manager.getNetworkOperatorName();

    return carrierName;
}

From source file:de.inhji.cordova.plugin.Telephony.java

/**
 * Ruft den Mobilfunkanbieter ab//from   w  ww  .j  a  v  a  2  s  .com
 */
private void getCarrier(CallbackContext ctx) {
    Context context = this.cordova.getActivity().getApplicationContext();
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String carrierName = manager.getNetworkOperatorName();

    PluginResult result = new PluginResult(PluginResult.Status.OK, carrierName);
    ctx.sendPluginResult(result);
}

From source file:ly.count.android.api.DeviceInfoTests.java

public void testGetCarrier_nullNetOperator() {
    final TelephonyManager mockTelephonyManager = mock(TelephonyManager.class);
    when(mockTelephonyManager.getNetworkOperatorName()).thenReturn(null);
    final Context mockContext = mock(Context.class);
    when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);
    assertEquals("", DeviceInfo.getCarrier(mockContext));
}

From source file:ly.count.android.api.DeviceInfoTests.java

public void testGetCarrier_emptyNetOperator() {
    final TelephonyManager mockTelephonyManager = mock(TelephonyManager.class);
    when(mockTelephonyManager.getNetworkOperatorName()).thenReturn("");
    final Context mockContext = mock(Context.class);
    when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);
    assertEquals("", DeviceInfo.getCarrier(mockContext));
}

From source file:ly.count.android.api.DeviceInfoTests.java

public void testGetCarrier() {
    final TelephonyManager mockTelephonyManager = mock(TelephonyManager.class);
    when(mockTelephonyManager.getNetworkOperatorName()).thenReturn("Verizon");
    final Context mockContext = mock(Context.class);
    when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);
    assertEquals("Verizon", DeviceInfo.getCarrier(mockContext));
}

From source file:com.fallahpoor.infocenter.fragments.SimFragment.java

private String getNetworkOperatorName(TelephonyManager telephonyManager) {

    String netOpName = telephonyManager.getNetworkOperatorName();

    if (Utils.isEmpty(netOpName)) {
        return getString(R.string.unknown);
    } else {/* w w  w.ja va 2  s . c  o  m*/
        return netOpName;
    }

}