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.
Nested classes | |
---|---|
class |
SubscriptionManager.OnSubscriptionsChangedListener
A listener class for monitoring changes to |
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 |
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 |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
int DATA_ROAMING_DISABLE
Indicates that data roaming is disabled for a subscription
Constant Value: 0 (0x00000000)
int DATA_ROAMING_ENABLE
Indicates that data roaming is enabled for a subscription
Constant Value: 1 (0x00000001)
int INVALID_SUBSCRIPTION_ID
An invalid subscription identifier
Constant Value: -1 (0xffffffff)
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.
|
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 |
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. |
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() .
|
int getActiveSubscriptionInfoCountMax ()
Returns | |
---|---|
int |
the maximum number of active subscriptions that will be returned by
getActiveSubscriptionInfoList() and the value returned by
getActiveSubscriptionInfoCount() .
|
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 |
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.
|
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. |
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. |
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. |
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. |
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 |
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.
|