Rethinavel
Rethinavel

Reputation: 3952

How do i get the carrier name of an incoming number in android..?

I am able to get the carrier name using the following snippet :

TelephonyManager telephonyManager = ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE));
String operatorName = telephonyManager.getNetworkOperatorName();

It works really fine.

I am also able to get the incoming call number using the following snippet:

private final PhoneStateListener phoneStateListener = new PhoneStateListener() {

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        String callState = "UNKNOWN";
        switch (state) {
            case TelephonyManager.CALL_STATE_RINGING:
        }
    }
}

I want to find out the carrier name / service provider name of an incoming number. How can I achieve that?
Is that possible to get the incoming number's location, say, for example the country?

Upvotes: 2

Views: 4056

Answers (3)

Kona Suresh
Kona Suresh

Reputation: 1854

from API Level 22 (Andrid 5.1) This APIs are available.

SubscriptionManager subscriptionManager = (SubscriptionManager)getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);

List<SubscriptionInfo> subscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();

if (subscriptionInfoList != null && subscriptionInfoList.size() > 0) {
    for (SubscriptionInfo info : subscriptionInfoList) {
        String carrierName = info.getCarrierName().toString();
        String mobileNo = info.getNumber();
        String countyIso = info.getCountryIso();
        int dataRoaming = info.getDataRoaming();
    }
}

Upvotes: 0

Yngwie89
Yngwie89

Reputation: 1217

It's not possible to get the carrier name of a whatever mobile number neither with the Android API. At least is not that easy (and you could fall into some privacy related issue i think).

Read this article for more information:

http://sms411.net/2006/07/finding-out-someones-carrier/

Of course you can try to find the original carrier (using the prefix), but that could be different from the actual one...

Upvotes: 3

Rajesh
Rajesh

Reputation: 15774

It is not possible to retrieve the details of the carrier of a calling party programatically. Also, because of number portability, it is not possible to retrieve the carrier's name from the caller's phone number. You can, however, get the country information from the first few digits of the number. Refer List of country calling codes for more information.

Upvotes: 2

Related Questions