public static class ConnectivityManager.NetworkCallback extends Object
Constructor and Description |
---|
NetworkCallback() |
Modifier and Type | Method and Description |
---|---|
void |
onAvailable(Network network)
Called when the framework connects and has declared a new network ready for use.
|
void |
onCapabilitiesChanged(Network network,
NetworkCapabilities networkCapabilities)
Called when the network the framework connected to for this request
changes capabilities but still satisfies the stated need.
|
void |
onLinkPropertiesChanged(Network network,
LinkProperties linkProperties)
Called when the network the framework connected to for this request
changes
LinkProperties . |
void |
onLosing(Network network,
int maxMsToLive)
Called when the network is about to be disconnected.
|
void |
onLost(Network network)
Called when the framework has a hard loss of the network or when the
graceful failure ends.
|
void |
onNetworkResumed(Network network)
Called when the network the framework connected to for this request
returns from a
NetworkInfo.DetailedState.SUSPENDED state. |
void |
onNetworkSuspended(Network network)
Called when the network the framework connected to for this request
goes into
NetworkInfo.DetailedState.SUSPENDED . |
void |
onPreCheck(Network network)
Called when the framework connects to a new network to evaluate whether it satisfies this
request.
|
void |
onUnavailable()
Called if no network is found in the given timeout time.
|
public void onPreCheck(Network network)
onAvailable(android.net.Network)
callback. There is no guarantee that this new network will satisfy any requests, or that
the network will stay connected for longer than the time necessary to evaluate it.
Most applications should not act on this callback, and should instead use
onAvailable(android.net.Network)
. This callback is intended for use by applications that can assist
the framework in properly evaluating the network — for example, an application that
can automatically log in to a captive portal without user intervention.
network
- The Network
of the network that is being evaluated.public void onAvailable(Network network)
Network
that is
satisfying the request changes.network
- The Network
of the satisfying network.public void onLosing(Network network, int maxMsToLive)
onAvailable(android.net.Network)
call with the new replacement network
for graceful handover. This may not be called if we have a hard loss
(loss without warning). This may be followed by either a
onLost(android.net.Network)
call or a
onAvailable(android.net.Network)
call for this network depending
on whether we lose or regain it.network
- The Network
that is about to be disconnected.maxMsToLive
- The time in ms the framework will attempt to keep the
network connected. Note that the network may suffer a
hard loss at any time.public void onLost(Network network)
network
- The Network
lost.public void onUnavailable()
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities)
network
- The Network
whose capabilities have changed.networkCapabilities
- The new NetworkCapabilities
for this network.public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties)
LinkProperties
.network
- The Network
whose link properties have changed.linkProperties
- The new LinkProperties
for this network.public void onNetworkSuspended(Network network)
NetworkInfo.DetailedState.SUSPENDED
.
This generally means that while the TCP connections are still live,
temporarily network data fails to transfer. Specifically this is used
on cellular networks to mask temporary outages when driving through
a tunnel, etc.public void onNetworkResumed(Network network)
NetworkInfo.DetailedState.SUSPENDED
state.
This should always be preceeded by a matching onNetworkSuspended
call.