public class SimpleNetworkCallbackAdapter extends android.net.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(android.net.Network network) |
void |
onCapabilitiesChanged(android.net.Network network,
android.net.NetworkCapabilities networkCapabilities) |
void |
onConnectivity(boolean isConnected)
Called when the connectivity state changes.
|
void |
onInternet(boolean hasInternet)
Called when the Internet state change.
|
void |
onLost(android.net.Network network) |
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 void setListener(@Nullable SimpleNetworkCallback listener)
listener
- the listener to set.public void onAvailable(android.net.Network network)
onAvailable
in class android.net.ConnectivityManager.NetworkCallback
public void onLost(android.net.Network network)
onLost
in class android.net.ConnectivityManager.NetworkCallback
public void onCapabilitiesChanged(android.net.Network network, android.net.NetworkCapabilities networkCapabilities)
onCapabilitiesChanged
in class android.net.ConnectivityManager.NetworkCallback
public void onInternet(boolean hasInternet)
onInternet
in interface SimpleNetworkCallback
hasInternet
- true
if Internet access is available.onCapabilitiesChanged(Network, NetworkCapabilities)
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 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.