public class NetStatusCallback extends Object
You can register a child class that inherits this class to listen for status changes of data networks.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
NetSpecifier |
networkRequest |
specifier network param
|
| 构造器 | 说明 |
|---|---|
NetStatusCallback() |
Constructor for this class
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onAvailable(NetHandle handle) |
A callback method used to notify applications of an available data network.
|
void |
onBlockedStatusChanged(NetHandle handle,
boolean blocked) |
A callback method used to notify applications of network congestion status changes.
|
void |
onCapabilitiesChanged(NetHandle handle,
NetCapabilities networkCapabilities) |
A callback method used to notify applications of network capability changes.
|
void |
onConnectionPropertiesChanged(NetHandle handle,
ConnectionProperties connectionProperties) |
A callback method used to notify applications of changes in network link parameters.
|
void |
onLosing(NetHandle handle,
long maxMsToLive) |
A callback method used to notify applications when a network disconnection is ongoing.
|
void |
onLost(NetHandle handle) |
Notifies applications of a serious network interruption or a normal network disconnection.
|
void |
onUnavailable() |
Notifies applications of a failure to set up a network connection
if no connection is set up before the
NetManager.setupSpecificNet(ohos.net.NetSpecifier, ohos.net.NetStatusCallback) request times out. |
public NetSpecifier networkRequest
public void onAvailable(NetHandle handle)
handle - Indicates the available NetHandle object.public void onBlockedStatusChanged(NetHandle handle, boolean blocked)
handle - Indicates the NetHandle object whose congestion status has changed.blocked - Specifies whether the network is congested.
The value true indicates that the network is congested,
and the value false indicates that the network is not congested.public void onLosing(NetHandle handle, long maxMsToLive)
handle - Indicates the NetHandle object that is undergoing a disconnection.maxMsToLive - Indicates the time remaining before the network becomes unavailable.public void onLost(NetHandle handle)
handle - Indicates the NetHandle object that has become unavailable.public void onUnavailable()
NetManager.setupSpecificNet(ohos.net.NetSpecifier, ohos.net.NetStatusCallback) request times out.public void onCapabilitiesChanged(NetHandle handle, NetCapabilities networkCapabilities)
handle - Indicates the NetHandle object whose capability has changed.networkCapabilities - Indicates the new NetCapabilities object.public void onConnectionPropertiesChanged(NetHandle handle, ConnectionProperties connectionProperties)
handle - Indicates the NetHandle object whose link parameters have changed.connectionProperties - Indicates the new ConnectionProperties object.