Get MCC/MNC id by entering phone number in Android

3.8k views Asked by At

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.

1

There are 1 answers

0
323go On

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.