Read Sim card name

776 Views Asked by At

In my dual sim smartphone I can set and change names for both sim cards:

Dual Sim settings

As you can see I set the name of the first sim card to "HOTLINE DE" and the second to "HOTLINE CH". I can change these names to whatever I want in the settings.

Now I want to read these names in the app I am working on, so I created a SubscriptionManager to read the SubscriptionInfos of the sim cards. This is the SubscriptionInfo of the first sim card:

enter image description here

I can't find the "HOTLINE DE" name in the object. All I get is the carrier name. Is there any way to read the user-set name of the sim card?

2

There are 2 best solutions below

0
On
val operatorName = (context.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager)?.networkOperatorName ?: "unknown"
0
On
List<SubscriptionInfo> subscriptionInfos = SubscriptionManager.from(getApplicationContext()).getActiveSubscriptionInfoList();
for(int i=0; i<subscriptionInfos.size();i++)
{
    SubscriptionInfo lsuSubscriptionInfo = subscriptionInfos.get(i);
    Log.d(TAG, "getNumber "+ lsuSubscriptionInfo.getNumber());
    Log.d(TAG, "network name : "+ lsuSubscriptionInfo.getCarrierName());
    Log.d(TAG, "getCountryIso "+ lsuSubscriptionInfo.getCountryIso());
}