Skip to content

Most visited

Recently visited

navigation

SubscriptionManager

public class SubscriptionManager
extends Object

java.lang.Object
   ↳ android.telephony.SubscriptionManager


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

int INVALID_SUBSCRIPTION_ID

An invalid subscription identifier

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

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

static int getDefaultDataSubscriptionId()

Returns the system's default data subscription id.

static int getDefaultSmsSubscriptionId()

Returns the system's default SMS subscription id.

static int getDefaultSubscriptionId()

Returns the system's default subscription id.

static int getDefaultVoiceSubscriptionId()

Returns the system's default voice subscription id.

boolean isNetworkRoaming(int subId)

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

void removeOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)

Unregister the SubscriptionManager.OnSubscriptionsChangedListener.

Inherited methods

From class java.lang.Object

Constants

DATA_ROAMING_DISABLE

added in API level 22
int DATA_ROAMING_DISABLE

Indicates that data roaming is disabled for a subscription

Constant Value: 0 (0x00000000)

DATA_ROAMING_ENABLE

added in API level 22
int DATA_ROAMING_ENABLE

Indicates that data roaming is enabled for a subscription

Constant Value: 1 (0x00000001)

INVALID_SUBSCRIPTION_ID

added in API level 24
int INVALID_SUBSCRIPTION_ID

An invalid subscription identifier

Constant Value: -1 (0xffffffff)

Public methods

addOnSubscriptionsChangedListener

added in API level 22
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 SubscriptionManager.OnSubscriptionsChangedListener: an instance of SubscriptionManager.OnSubscriptionsChangedListener with onSubscriptionsChanged overridden.

from

added in API level 22
SubscriptionManager from (Context context)

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

Parameters
context Context: to use.
Returns
SubscriptionManager SubscriptionManager instance

getActiveSubscriptionInfo

added in API level 22
SubscriptionInfo getActiveSubscriptionInfo (int subId)

Get the active SubscriptionInfo with the input subId.

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

getActiveSubscriptionInfoCount

added in API level 22
int getActiveSubscriptionInfoCount ()

Returns
int 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().

getActiveSubscriptionInfoCountMax

added in API level 22
int getActiveSubscriptionInfoCountMax ()

Returns
int the maximum number of active subscriptions that will be returned by getActiveSubscriptionInfoList() and the value returned by getActiveSubscriptionInfoCount().

getActiveSubscriptionInfoForSimSlotIndex

added in API level 22
SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex (int slotIdx)

Get the active SubscriptionInfo associated with the slotIdx

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

getActiveSubscriptionInfoList

added in API level 22
List<SubscriptionInfo> getActiveSubscriptionInfoList ()

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

Returns
List<SubscriptionInfo> Sorted list of the currently SubscriptionInfo records available on the device.

getDefaultDataSubscriptionId

added in API level 24
int getDefaultDataSubscriptionId ()

Returns the system's default data subscription id. On a voice only device or on error, will return INVALID_SUBSCRIPTION_ID.

Returns
int the default data subscription Id.

getDefaultSmsSubscriptionId

added in API level 24
int getDefaultSmsSubscriptionId ()

Returns the system's default SMS subscription id. On a data only device or on error, will return INVALID_SUBSCRIPTION_ID.

Returns
int the default SMS subscription Id.

getDefaultSubscriptionId

added in API level 24
int getDefaultSubscriptionId ()

Returns the system's default subscription id. For a voice capable device, it will return getDefaultVoiceSubscriptionId. For a data only device, it will return the getDefaultDataSubscriptionId. May return an INVALID_SUBSCRIPTION_ID on error.

Returns
int the "system" default subscription id.

getDefaultVoiceSubscriptionId

added in API level 24
int getDefaultVoiceSubscriptionId ()

Returns the system's default voice subscription id. On a data only device or on error, will return INVALID_SUBSCRIPTION_ID.

Returns
int the default voice subscription Id.

isNetworkRoaming

added in API level 22
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 int: The subscription ID
Returns
boolean true if the network for the subscription is roaming, false otherwise

removeOnSubscriptionsChangedListener

added in API level 22
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 SubscriptionManager.OnSubscriptionsChangedListener: that is to be unregistered.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.