public class CellularDataInfoManager extends Object
This class provides methods for querying and setting the state of cellular data services and monitoring the state.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
DATA_FLOW_TYPE_DORMANT |
Indicates that there is no uplink or downlink data, and the bottom-layer link is in the dormant state.
|
static int |
DATA_FLOW_TYPE_DOWN |
Indicates that there is only downlink data.
|
static int |
DATA_FLOW_TYPE_NONE |
Indicates that there is no uplink or downlink data.
|
static int |
DATA_FLOW_TYPE_UP |
Indicates that there is only uplink data.
|
static int |
DATA_FLOW_TYPE_UPDOWN |
Indicates that there is uplink and downlink data.
|
static int |
DATA_STATE_CONNECTED |
Indicates that a cellular data link is connected.
|
static int |
DATA_STATE_CONNECTING |
Indicates that a cellular data link is being connected.
|
static int |
DATA_STATE_DISCONNECTED |
Indicates that a cellular data link is disconnected.
|
static int |
DATA_STATE_SUSPENDED |
Indicates that a cellular data link is suspended.
|
static int |
DATA_STATE_UNKNOWN |
Indicates that a cellular data link is unknown.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addObserver(CellularDataStateObserver observer,
int mask) |
Adds an observer for monitoring cellular data service state changes.
|
int |
getCellularDataFlowType() |
Obtains the uplink and downlink status of cellular data services.
|
int |
getCellularDataState(int slotId) |
Obtains the connection state of the PS domain.
|
int |
getDefaultCellularDataSlotId() |
Obtains the SIM card where cellular data services are available.
|
static CellularDataInfoManager |
getInstance(Context context) |
Obtains a
CellularDataInfoManager instance. |
boolean |
isCellularDataEnabled() |
Checks whether cellular data services are enabled.
|
boolean |
isCellularDataRoamingEnabled(int slotId) |
Checks whether roaming is enabled for cellular data services.
|
void |
removeObserver(CellularDataStateObserver observer) |
Removes an observer for monitoring cellular data service state changes.
|
public static final int DATA_FLOW_TYPE_DORMANT
It is a return value of service state query of cellular data services.
public static final int DATA_FLOW_TYPE_DOWN
It is a return value of service state query of cellular data services.
public static final int DATA_FLOW_TYPE_NONE
It is a return value of service state query of cellular data services.
public static final int DATA_FLOW_TYPE_UP
It is a return value of service state query of cellular data services.
public static final int DATA_FLOW_TYPE_UPDOWN
It is a return value of service state query of cellular data services.
public static final int DATA_STATE_CONNECTED
It is a return value for querying the cellular data link connection state.
public static final int DATA_STATE_CONNECTING
It is a return value for querying the cellular data link connection state.
public static final int DATA_STATE_DISCONNECTED
It is a return value for querying the cellular data link connection state.
public static final int DATA_STATE_SUSPENDED
It is a return value for querying the cellular data link connection state.
public static final int DATA_STATE_UNKNOWN
It is a return value for querying the cellular data link connection state.
public static CellularDataInfoManager getInstance(Context context)
CellularDataInfoManager instance.context - Indicates the application context.CellularDataInfoManager instance.public int getCellularDataFlowType()
DATA_FLOW_TYPE_NONE.public boolean isCellularDataEnabled()
Requires Permission: ohos.permission.GET_NETWORK_INFO.
true if cellular data services are enabled; returns false otherwise.public boolean isCellularDataRoamingEnabled(int slotId)
Requires Permission: ohos.permission.GET_NETWORK_INFO.
slotId - Indicates the ID of a card slot.
The value 0 indicates card 1, and the value 1 indicates card 2.true if roaming is enabled for cellular data services; returns false otherwise.public int getCellularDataState(int slotId)
slotId - Indicates the ID of a card slot.
The value 0 indicates card 1, and the value 1 indicates card 2.DATA_STATE_UNKNOWN
DATA_STATE_DISCONNECTED
DATA_STATE_CONNECTING
DATA_STATE_CONNECTED
DATA_STATE_SUSPENDED
public int getDefaultCellularDataSlotId()
0 if cellular data services are available on card 1;
returns 1 if they are available on card 2.public void addObserver(CellularDataStateObserver observer, int mask)
You must override the CellularDataStateObserver class to register an observer to monitor state
changes. When the state changes, the corresponding CellularDataStateObserver instance is invoked
to notify the application of the changes.
observer - Indicates the observer instance for state monitoring.mask - Indicates the state mask to be monitored, which can be either of the following:
public void removeObserver(CellularDataStateObserver observer)
observer - Indicates the observer instance for state monitoring.