Android - NetworkInfo对象的isConnected()与isAvailable()

xiaoxiao2021-02-28  16


Indicates whether network connectivity is possible. A network is unavailable when a persistent or semi-persistent condition prevents the possibility of connecting to that network. Examples include boolean isAvailable () The device is out of the coverage area for any network of this type.The device is on a network other than the home network (i.e., roaming), and data roaming has been disabled.The device's radio is turned off, e.g., because airplane mode is enabled.


Indicates whether network connectivity exists and it is possible to establish connections and pass data.

Always call this before attempting to perform data transactions.