-3

I am trying to find how to get a MCC/MNC id code (also called PLMN code) for a given cellphone number in Android. I am trying to determine which carrier the number is on before making a call.

condit
  • 10,852
  • 2
  • 41
  • 60

1 Answers1

1

You can only retrieve the MCC/MNC for your own phone, not for that of any given cellular number:

    TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String networkOperator = tel.getNetworkOperator();

    if (networkOperator != null) {
        int mcc = Integer.parseInt(networkOperator.substring(0, 3));
        int mnc = Integer.parseInt(networkOperator.substring(3));
    }

Phone calls are targeted at a PHONE number, regardless of the MCC/MNC of the receiving device. Unless you can obtain access to a third-party database to resolve a phone number to an operator, you're out of luck here. I'm unaware of any such database.

323go
  • 14,143
  • 6
  • 33
  • 41