Android APIs
public class

SubscriptionManager

extends Object
java.lang.Object
   ↳ android.telephony.SubscriptionManager

Class Overview

SubscriptionManager is the application interface to SubscriptionController and provides information about the current Telephony Subscriptions. *

You do not instantiate this class directly; instead, you retrieve a reference to an instance through from(Context).

All SDK public methods require android.Manifest.permission.READ_PHONE_STATE.

Summary

Nested Classes
class SubscriptionManager.OnSubscriptionsChangedListener A listener class for monitoring changes to SubscriptionInfo records. 
Constants
int DATA_ROAMING_DISABLE Indicates that data roaming is disabled for a subscription
int DATA_ROAMING_ENABLE Indicates that data roaming is enabled for a subscription
Public Methods
void addOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)
Register for changes to the list of active SubscriptionInfo records or to the individual records themselves.
static SubscriptionManager from(Context context)
Get an instance of the SubscriptionManager from the Context.
SubscriptionInfo getActiveSubscriptionInfo(int subId)
Get the active SubscriptionInfo with the subId key
int getActiveSubscriptionInfoCount()
int getActiveSubscriptionInfoCountMax()
SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIdx)
Get the active SubscriptionInfo associated with the slotIdx
List<SubscriptionInfo> getActiveSubscriptionInfoList()
Get the SubscriptionInfo(s) of the currently inserted SIM(s).
boolean isNetworkRoaming(int subId)
Returns true if the device is considered roaming on the current network for a subscription.
void removeOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int DATA_ROAMING_DISABLE

Indicates that data roaming is disabled for a subscription

Constant Value: 0 (0x00000000)

public static final int DATA_ROAMING_ENABLE

Indicates that data roaming is enabled for a subscription

Constant Value: 1 (0x00000001)

Public Methods

public void addOnSubscriptionsChangedListener (SubscriptionManager.OnSubscriptionsChangedListener listener)

Register for changes to the list of active SubscriptionInfo records or to the individual records themselves. When a change occurs the onSubscriptionsChanged method of the listener will be invoked immediately if there has been a notification.

Parameters
listener an instance of SubscriptionManager.OnSubscriptionsChangedListener with onSubscriptionsChanged overridden.

public static SubscriptionManager from (Context context)

Get an instance of the SubscriptionManager from the Context. This invokes Context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE).

Parameters
context to use.
Returns
  • SubscriptionManager instance

public SubscriptionInfo getActiveSubscriptionInfo (int subId)

Get the active SubscriptionInfo with the subId key

Parameters
subId The unique SubscriptionInfo key in database
Returns
  • SubscriptionInfo, maybe null if its not active.

public int getActiveSubscriptionInfoCount ()

Returns
  • the current number of active subscriptions. There is no guarantee the value returned by this method will be the same as the length of the list returned by getActiveSubscriptionInfoList().

public int getActiveSubscriptionInfoCountMax ()

Returns

public SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex (int slotIdx)

Get the active SubscriptionInfo associated with the slotIdx

Parameters
slotIdx the slot which the subscription is inserted
Returns
  • SubscriptionInfo, maybe null if its not active

public List<SubscriptionInfo> getActiveSubscriptionInfoList ()

Get the SubscriptionInfo(s) of the currently inserted SIM(s). The records will be sorted by getSimSlotIndex() then by getSubscriptionId().

Returns

public boolean isNetworkRoaming (int subId)

Returns true if the device is considered roaming on the current network for a subscription.

Availability: Only when user registered to a network.

Parameters
subId The subscription ID
Returns
  • true if the network for the subscription is roaming, false otherwise

public void removeOnSubscriptionsChangedListener (SubscriptionManager.OnSubscriptionsChangedListener listener)

Unregister the SubscriptionManager.OnSubscriptionsChangedListener. This is not strictly necessary as the listener will automatically be unregistered if an attempt to invoke the listener fails.

Parameters
listener that is to be unregistered.