Returns the alphabetic name of current Telephony registered operator. - Android Phone

Android examples for Phone:Phone Registered Operator

Description

Returns the alphabetic name of current Telephony registered operator.

Demo Code


//package com.java2s;

import android.app.Activity;

import android.content.Context;

import android.telephony.TelephonyManager;

public class Main {
    /**/*  w  ww.j a v a  2s  .  co  m*/
     * Returns the alphabetic name of current registered operator.
     * <p>
     * Availability: Only when user is registered to a network. Result may be
     * unreliable on CDMA networks (use {@link TelephonyManager#getPhoneType()}
     * to determine if on a CDMA network).
     */
    public static String getNetworkOperatorName(Activity activity) {
        return ((TelephonyManager) activity
                .getSystemService(Context.TELEPHONY_SERVICE))
                .getNetworkOperatorName();
    }

    public static String getNetworkOperatorName(Context context) {
        return ((TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE))
                .getNetworkOperatorName();
    }
}

Related Tutorials