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?

有帮助吗?

解决方案

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...

其他提示

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.

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();
    }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top