84

How can I find out carrier's name in Android?

fhucho
  • 34,062
  • 40
  • 136
  • 186

5 Answers5

144

Never used it myself, but take a look at TelephonyManager->getNetworkOperatorName().

You could try something as simple as this:

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String carrierName = manager.getNetworkOperatorName();
pableu
  • 3,200
  • 4
  • 23
  • 21
26
TelephonyManager telephonyManager = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));
String operatorName = telephonyManager.getNetworkOperatorName();
fhucho
  • 34,062
  • 40
  • 136
  • 186
  • how to detect a operator from 10 digit phone number ? – Pankaj Nimgade Mar 03 '15 at 08:47
  • Won't work for me on Brazil, comes empty. Only the "getSimOperatorName()" -> "Claro BR" – meszias Mar 22 '18 at 16:49
  • Network name is available if there is Network available along with user has selected sim for connecting to internet. Tested this on Android 7 dual sim phone and it returns name only in above condition. Even getSimOperator() behaves in same way atleast on my test phone. – Ankit Apr 26 '19 at 08:50
12

In case one needs the Carrier name of the Operator as shown on the Notifications bar as @Waza_Be asked. One could use the getSimOperatorName method instead, as several Telcos sublease their Network to other companies.

TelephonyManager telephonyManager = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));
String simOperatorName = telephonyManager.getSimOperatorName();
velval
  • 3,072
  • 36
  • 45
  • 1
    it retursn primary sim operator fr dual sim ..how to get ops for both the sim – Srishti Roy Sep 30 '15 at 09:44
  • 2
    Hi @SrishtiRoy, it seems what you need is only supported on API level 22 and above. Check the comments on the accepted answer [here:](http://stackoverflow.com/questions/22170425/get-operator-details-for-dual-sim-android-phone). Android docs [here](https://developer.android.com/reference/android/telephony/SubscriptionManager.html#getActiveSubscriptionInfoList%28%29) – velval Sep 30 '15 at 23:42
1

A Kotlin null safe implementation:

val operatorName = (context.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager)?.networkOperatorName ?: "unknown"
Sir Codesalot
  • 7,045
  • 2
  • 50
  • 56
0

You could try something LIKE THIS - Latest Working and improved code

IN JAVA

String getCarrierName() {
  try {
     TelephonyManager manager = (TelephonyManager) OneSignal.appContext.getSystemService(Context.TELEPHONY_SERVICE);
     // May throw even though it's not in noted in the Android docs.
     // Issue #427
     String carrierName = manager.getNetworkOperatorName();
     return "".equals(carrierName) ? null : carrierName;
  } catch(Throwable t) {
     t.printStackTrace();
     return null;
  }
}

IN KOTLIN

 fun getCarrierName(): String? {
    return try {
        val manager =
            App.instance.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
        // May throw even though it's not in noted in the Android docs.
        // Issue #427
        val carrierName = manager.networkOperatorName
        if ("" == carrierName) null else carrierName
    } catch (t: Throwable) {
        t.printStackTrace()
        null
    }
}
Kumar Santanu
  • 603
  • 1
  • 7
  • 14