Reputation: 55
I am creating an app with minimum sdk version 16.My question is how to get the carrier name of both the carriers in a dual sim phone.
I used this code but it dosenot work with sdk v16
TelephonyManager telephonyManager = ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE));
And also I want to get the name of the carrier in string format.
Upvotes: 3
Views: 1506
Reputation: 1141
SubscriptionManager
is available in API 22
use the following code to get carrier names for dual sim phone
SubscriptionManager subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
List<String> carrierNames = new ArrayList<>();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
for (int i = 0; i < subscriptionInfos.size(); i++) {
carrierNames.add(subscriptionInfos.get(i).getCarrierName().toString());
}
}
Upvotes: 1