public class RadioStateObserver extends Object
You can use RadioInfoManager#addObserver to add the RadioStateObserver
with a specific observer mask. The corresponding method is invoked when the state updates.
You need to override the method to receive the state information. Access to certain information
is permission-protected. You must declare the appropriate permissions in the profile of the application.
You can use RadioInfoManager#removeObserver to delete the RadioStateObserver.
The observer must be the same as that added.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
OBSERVE_MASK_CELL_INFO |
Indicates an observer mask for cell information updates.
|
static int |
OBSERVE_MASK_NETWORK_STATE |
Indicates an observer mask for network state updates.
|
static int |
OBSERVE_MASK_SIGNAL_INFO |
Indicates an observer mask for signal strength updates.
|
protected int |
slotId |
Indicates the slot ID to observe updates.
|
| 构造器 | 说明 |
|---|---|
RadioStateObserver(int slotId) |
Callback will be invoked in the current thread, which must have a runner.
|
RadioStateObserver(int slotId,
EventRunner runner) |
Callback will be invoked in the specified runner thread.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onNetworkStateUpdated(NetworkState networkState) |
Called when the network state corresponding to a monitored
slotId updates. |
void |
onSignalInfoUpdated(List<SignalInformation> signalInfos) |
Called when the signal strength corresponding to a monitored
slotId updates. |
public static final int OBSERVE_MASK_CELL_INFO
Applications must have the ohos.permission.LOCATION permission
to register this event.
public static final int OBSERVE_MASK_NETWORK_STATE
Applications must have the ohos.permission.GET_NETWORK_INFO permission
to register this event.
onNetworkStateUpdated(ohos.telephony.NetworkState),
常量字段值public static final int OBSERVE_MASK_SIGNAL_INFO
onSignalInfoUpdated(java.util.List<ohos.telephony.SignalInformation>),
常量字段值protected int slotId
public RadioStateObserver(int slotId)
public RadioStateObserver(int slotId,
EventRunner runner)
slotId - Indicates the slot ID you want to observe.runner - Indicates the event handler.IllegalArgumentException - Throws this exception if an invalid runner is used.public void onNetworkStateUpdated(NetworkState networkState)
slotId updates.
The value of slotId is passed from the constructor during class initialization.
You must override this method to observe these updates.
networkState - Indicates an instance of the NetworkState class.public void onSignalInfoUpdated(List<SignalInformation> signalInfos)
slotId updates.
The value of slotId is passed from the constructor during class initialization.
You must override this method to observe these updates.
signalInfos - Indicates a list of instances of the classes derived from SignalInformation.