Most visited

Recently visited

Added in API level 22

SubscriptionManager

public class SubscriptionManager
extends Object

java.lang.Object
   ↳ android.telephony.SubscriptionManager


SubscriptionManager是SubscriptionController的应用程序接口,提供有关当前电话订阅的信息。 *

你不直接实例化这个类; 相反,您通过from(Context)获取对实例的引用。

所有的SDK公共方法都需要android.Manifest.permission.READ_PHONE_STATE。

Summary

Nested classes

class SubscriptionManager.OnSubscriptionsChangedListener

一个监听器类,用于监视对SubscriptionInfo记录的更改。

Constants

int DATA_ROAMING_DISABLE

表示为订阅禁用数据漫游

int DATA_ROAMING_ENABLE

表示为订阅启用了数据漫游

int INVALID_SUBSCRIPTION_ID

无效的订阅标识符

Public methods

void addOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)

注册修改活动的 SubscriptionInfo记录列表或记录本身。

static SubscriptionManager from(Context context)

从上下文获取SubscriptionManager的实例。

SubscriptionInfo getActiveSubscriptionInfo(int subId)

使用输入subId获取活动的SubscriptionInfo。

int getActiveSubscriptionInfoCount()
int getActiveSubscriptionInfoCountMax()
SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIdx)

获取与slotIdx关联的活动SubscriptionInfo

List<SubscriptionInfo> getActiveSubscriptionInfoList()

获取当前插入的SIM卡的SubscriptionInfo(s)。

static int getDefaultDataSubscriptionId()

返回系统的默认数据订阅ID。

static int getDefaultSmsSubscriptionId()

返回系统的默认SMS订阅ID。

static int getDefaultSubscriptionId()

返回系统的默认订阅ID。

static int getDefaultVoiceSubscriptionId()

返回系统的默认语音订阅ID。

boolean isNetworkRoaming(int subId)

如果设备被认为在当前网络上漫游以进行订阅,则返回true。

void removeOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)

取消注册 SubscriptionManager.OnSubscriptionsChangedListener

Inherited methods

From class java.lang.Object

Constants

DATA_ROAMING_DISABLE

Added in API level 22
int DATA_ROAMING_DISABLE

表示为订阅禁用数据漫游

常量值:0(0x00000000)

DATA_ROAMING_ENABLE

Added in API level 22
int DATA_ROAMING_ENABLE

表示为订阅启用了数据漫游

常数值:1(0x00000001)

INVALID_SUBSCRIPTION_ID

Added in API level 24
int INVALID_SUBSCRIPTION_ID

无效的订阅标识符

常量值:-1(0xffffffff)

Public methods

addOnSubscriptionsChangedListener

Added in API level 22
void addOnSubscriptionsChangedListener (SubscriptionManager.OnSubscriptionsChangedListener listener)

注册修改活动的SubscriptionInfo记录列表或记录本身。 发生更改时,如果发出通知,将立即调用侦听器的onSubscriptionsChanged方法。

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

from

Added in API level 22
SubscriptionManager from (Context context)

从上下文获取SubscriptionManager的实例。 这会调用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)

使用输入subId获取活动的SubscriptionInfo。

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)

获取与slotIdx关联的活动SubscriptionInfo

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

获取当前插入的SIM卡的SubscriptionInfo(s)。 记录将按getSimSlotIndex()然后按getSubscriptionId()排序。

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

getDefaultDataSubscriptionId

Added in API level 24
int getDefaultDataSubscriptionId ()

返回系统的默认数据订阅ID。 在仅限语音设备或出错时,将返回INVALID_SUBSCRIPTION_ID。

Returns
int the default data subscription Id.

getDefaultSmsSubscriptionId

Added in API level 24
int getDefaultSmsSubscriptionId ()

返回系统的默认SMS订阅ID。 在数据专用设备上或发生错误时,将返回INVALID_SUBSCRIPTION_ID。

Returns
int the default SMS subscription Id.

getDefaultSubscriptionId

Added in API level 24
int getDefaultSubscriptionId ()

返回系统的默认订阅ID。 对于支持语音的设备,它将返回getDefaultVoiceSubscriptionId。 对于仅数据设备,它将返回getDefaultDataSubscriptionId。 错误时可能会返回INVALID_SUBSCRIPTION_ID。

Returns
int the "system" default subscription id.

getDefaultVoiceSubscriptionId

Added in API level 24
int getDefaultVoiceSubscriptionId ()

返回系统的默认语音订阅ID。 在数据专用设备上或发生错误时,将返回INVALID_SUBSCRIPTION_ID。

Returns
int the default voice subscription Id.

isNetworkRoaming

Added in API level 22
boolean isNetworkRoaming (int subId)

如果设备被认为在当前网络上漫游以进行订阅,则返回true。

可用性:仅当用户注册到网络时。

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)

取消注册SubscriptionManager.OnSubscriptionsChangedListener 这并非严格必要,因为如果尝试调用侦听器失败,监听器将自动取消注册。

Parameters
listener SubscriptionManager.OnSubscriptionsChangedListener: that is to be unregistered.

Hooray!