public class SimpleNetworkCallbackAdapter extends ConnectivityManager.NetworkCallback implements SimpleNetworkCallback
Constructor and Description |
---|
SimpleNetworkCallbackAdapter()
Instantiates a
SimpleNetworkCallback . |
SimpleNetworkCallbackAdapter(SimpleNetworkCallback listener)
Instantiates a
SimpleNetworkCallback . |
Modifier and Type | Method and Description |
---|---|
SimpleNetworkCallback |
getListener()
Gets the listener to call back on state change.
|
boolean |
hasInternet()
Checks whether the call back had been called for Internet.
|
boolean |
isConnected()
Checks whether the call back had been called for connection.
|
void |
onAvailable(Network network)
Called when the framework connects and has declared 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 |
onConnectivity(boolean isConnected)
Called when the connectivity state changes.
|
void |
onInternet(boolean hasInternet)
Called when the Internet state change.
|
void |
onLost(Network network)
Called when the framework has a hard loss of the network or when the graceful failure ends.
|
void |
setListener(SimpleNetworkCallback listener)
Sets the listener to call back on state change.
|
public SimpleNetworkCallbackAdapter()
SimpleNetworkCallback
.public SimpleNetworkCallbackAdapter(@Nullable SimpleNetworkCallback listener)
SimpleNetworkCallback
.listener
- the listener to call onstate change.public SimpleNetworkCallback getListener()
null
if none.public boolean hasInternet()
true
if the last call of onInternet(boolean)
had Internet.public boolean isConnected()
true
if the last call of onConnectivity(boolean)
was connected.public void onAvailable(Network network)
ConnectivityManager.NetworkCallback
Network
that is satisfying the request changes.onAvailable
in class ConnectivityManager.NetworkCallback
network
- The Network
of the satisfying network.public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities)
ConnectivityManager.NetworkCallback
onCapabilitiesChanged
in class ConnectivityManager.NetworkCallback
network
- The Network
of the satisfying network.networkCapabilities
- NetworkCapabilities: The new NetworkCapabilities
for this network.public void onConnectivity(boolean isConnected)
onConnectivity
in interface SimpleNetworkCallback
isConnected
- true
if a network is available.ConnectivityManager.NetworkCallback.onAvailable(Network)
,
ConnectivityManager.NetworkCallback.onLost(Network)
public void onInternet(boolean hasInternet)
onInternet
in interface SimpleNetworkCallback
hasInternet
- true
if Internet access is available.onCapabilitiesChanged(Network, NetworkCapabilities)
public void onLost(Network network)
ConnectivityManager.NetworkCallback
onLost
in class ConnectivityManager.NetworkCallback
network
- The Network
lost.public void setListener(@Nullable SimpleNetworkCallback listener)
listener
- the listener to set.