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

流过昼夜 提交于 2019-11-29 08:45:22

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.

Kona Suresh

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();
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!