Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Constants](https://developer.android.com/reference/android/net/NetworkInfo#inhconstants) \| [Fields](https://developer.android.com/reference/android/net/NetworkInfo#lfields) \| [Ctors](https://developer.android.com/reference/android/net/NetworkInfo#pubctors) \| [Methods](https://developer.android.com/reference/android/net/NetworkInfo#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/NetworkInfo#inhmethods)

# NetworkInfo

*** ** * ** ***

` public class NetworkInfo `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/android/os/Parcelable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.NetworkInfo |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 29.**   

Callers should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes, or switch to use `https://developer.android.com/reference/android/net/ConnectivityManager#getNetworkCapabilities(android.net.Network)` or `https://developer.android.com/reference/android/net/ConnectivityManager#getLinkProperties(android.net.Network)` to get information synchronously. Keep in mind that while callbacks are guaranteed to be called for every event in order, synchronous calls have no such constraints, and as such it is unadvisable to use the synchronous methods inside the callbacks as they will often not offer a view of networking that is consistent (that is: they may return a past or a future state with respect to the event being processed by the callback). Instead, callers are advised to only use the arguments of the callbacks, possibly memorizing the specific bits of information they need to keep from one callback to another.

Describes the status of a network interface.

Use `https://developer.android.com/reference/android/net/ConnectivityManager#getActiveNetworkInfo()` to get an instance that represents the current network connection.

## Summary

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor.
`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`".

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/net/NetworkInfo>` | `https://developer.android.com/reference/android/net/NetworkInfo#CREATOR` <br /> |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/NetworkInfo#NetworkInfo(int,%20int,%20java.lang.String,%20java.lang.String)(int type, int subtype, https://developer.android.com/reference/java/lang/String typeName, https://developer.android.com/reference/java/lang/String subtypeName) ` Create a new instance of NetworkInfo. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/net/NetworkInfo#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` https://developer.android.com/reference/android/net/NetworkInfo.DetailedState` | ` https://developer.android.com/reference/android/net/NetworkInfo#getDetailedState()() ` *This method is deprecated. Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. See `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.* |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/NetworkInfo#getExtraInfo()() ` *This method is deprecated. Use other services e.g. WifiManager to get additional information passed up from the lower networking layers.* |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/NetworkInfo#getReason()() ` *This method was deprecated in API level 28. This method does not have a consistent contract that could make it useful to callers.* |
| ` https://developer.android.com/reference/android/net/NetworkInfo.State` | ` https://developer.android.com/reference/android/net/NetworkInfo#getState()() ` *This method was deprecated in API level 28. Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.* |
| ` int` | ` https://developer.android.com/reference/android/net/NetworkInfo#getSubtype()() ` *This method was deprecated in API level 29. Use `https://developer.android.com/reference/android/telephony/TelephonyManager#getDataNetworkType()` instead.* |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/NetworkInfo#getSubtypeName()() ` *This method was deprecated in API level 29. Use `https://developer.android.com/reference/android/telephony/TelephonyManager#getDataNetworkType()` instead.* |
| ` int` | ` https://developer.android.com/reference/android/net/NetworkInfo#getType()() ` *This method was deprecated in API level 28. Callers should switch to checking `https://developer.android.com/reference/android/net/NetworkCapabilities#hasTransport(int)` instead with one of the NetworkCapabilities#TRANSPORT_\* constants : `https://developer.android.com/reference/android/net/NetworkInfo#getType()` and `https://developer.android.com/reference/android/net/NetworkInfo#getTypeName()` cannot account for networks using multiple transports. Note that generally apps should not care about transport; `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_METERED` and `https://developer.android.com/reference/android/net/NetworkCapabilities#getLinkDownstreamBandwidthKbps()` are calls that apps concerned with meteredness or bandwidth should be looking at, as they offer this information with much better accuracy.* |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/NetworkInfo#getTypeName()() ` *This method was deprecated in API level 28. Callers should switch to checking `https://developer.android.com/reference/android/net/NetworkCapabilities#hasTransport(int)` instead with one of the NetworkCapabilities#TRANSPORT_\* constants : `https://developer.android.com/reference/android/net/NetworkInfo#getType()` and `https://developer.android.com/reference/android/net/NetworkInfo#getTypeName()` cannot account for networks using multiple transports. Note that generally apps should not care about transport; `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_METERED` and `https://developer.android.com/reference/android/net/NetworkCapabilities#getLinkDownstreamBandwidthKbps()` are calls that apps concerned with meteredness or bandwidth should be looking at, as they offer this information with much better accuracy.* |
| ` boolean` | ` https://developer.android.com/reference/android/net/NetworkInfo#isAvailable()() ` *This method was deprecated in API level 28. Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.* |
| ` boolean` | ` https://developer.android.com/reference/android/net/NetworkInfo#isConnected()() ` *This method is deprecated. Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. See `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.* |
| ` boolean` | ` https://developer.android.com/reference/android/net/NetworkInfo#isConnectedOrConnecting()() ` *This method was deprecated in API level 28. Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.* |
| ` boolean` | ` https://developer.android.com/reference/android/net/NetworkInfo#isFailover()() ` *This method was deprecated in API level 28. This field is not populated in recent Android releases, and does not make a lot of sense in a multi-network world.* |
| ` boolean` | ` https://developer.android.com/reference/android/net/NetworkInfo#isRoaming()() ` *This method was deprecated in API level 28. Callers should switch to checking `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_ROAMING` instead, since that handles more complex situations, such as VPNs.* |
| ` void` | ` https://developer.android.com/reference/android/net/NetworkInfo#setDetailedState(android.net.NetworkInfo.DetailedState,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/android/net/NetworkInfo.DetailedState detailedState, https://developer.android.com/reference/java/lang/String reason, https://developer.android.com/reference/java/lang/String extraInfo) ` *This method was deprecated in API level 29. Use `https://developer.android.com/reference/android/net/NetworkCapabilities` instead.* |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/NetworkInfo#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/net/NetworkInfo#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/os/Parcelable ` ` abstract int` ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() `

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
` abstract void` ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) `

Flatten this object in to a Parcel.

## Fields

### CREATOR

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<NetworkInfo> CREATOR
```

<br />

<br />

## Public constructors

### NetworkInfo

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public NetworkInfo (int type, 
                int subtype, 
                String typeName, 
                String subtypeName)
```

Create a new instance of NetworkInfo. This may be useful for apps to write unit tests.

<br />

| Parameters ||
|---|---|
| `type` | `int`: the legacy type of the network, as one of the ConnectivityManager.TYPE_\* constants. <br /> |
| `subtype` | `int`: the subtype if applicable, as one of the TelephonyManager.NETWORK_TYPE_\* constants. <br /> |
| `typeName` | `String`: a human-readable string for the network type, or an empty string or null. <br /> |
| `subtypeName` | `String`: a human-readable string for the subtype, or an empty string or null. <br /> |

## Public methods

### describeContents

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`, the return value of this method must include the `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getDetailedState

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public NetworkInfo.DetailedState getDetailedState ()
```

<br />

**This method is deprecated.**   

Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. See `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.

Reports the current fine-grained state of the network.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/NetworkInfo.DetailedState` | the fine-grained state. This value cannot be `null`. <br /> |

### getExtraInfo

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getExtraInfo ()
```

<br />

**This method is deprecated.**   

Use other services e.g. WifiManager to get additional information passed up from the lower networking layers.

Report the extra information about the network state, if any was provided by the lower networking layers.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the extra information, or null if not available <br /> |

### getReason

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getReason ()
```

<br />

**This method was deprecated in API level 28.**   

This method does not have a consistent contract that could make it useful to callers.

Report the reason an attempt to establish connectivity failed, if one is available.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the reason for failure, or null if not available <br /> |

### getState

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public NetworkInfo.State getState ()
```

<br />

**This method was deprecated in API level 28.**   

Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.

Reports the current coarse-grained state of the network.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/NetworkInfo.State` | the coarse-grained state <br /> |

### getSubtype

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSubtype ()
```

<br />

**This method was deprecated in API level 29.**   

Use `https://developer.android.com/reference/android/telephony/TelephonyManager#getDataNetworkType()` instead.

Return a network-type-specific integer describing the subtype of the network.

<br />

| Returns ||
|---|---|
| `int` | the network subtype <br /> |

### getSubtypeName

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getSubtypeName ()
```

<br />

**This method was deprecated in API level 29.**   

Use `https://developer.android.com/reference/android/telephony/TelephonyManager#getDataNetworkType()` instead.

Return a human-readable name describing the subtype of the network.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the name of the network subtype <br /> |

### getType

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getType ()
```

<br />

**This method was deprecated in API level 28.**   

Callers should switch to checking `https://developer.android.com/reference/android/net/NetworkCapabilities#hasTransport(int)` instead with one of the NetworkCapabilities#TRANSPORT_\* constants : `https://developer.android.com/reference/android/net/NetworkInfo#getType()` and `https://developer.android.com/reference/android/net/NetworkInfo#getTypeName()` cannot account for networks using multiple transports. Note that generally apps should not care about transport; `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_METERED` and `https://developer.android.com/reference/android/net/NetworkCapabilities#getLinkDownstreamBandwidthKbps()` are calls that apps concerned with meteredness or bandwidth should be looking at, as they offer this information with much better accuracy.

Reports the type of network to which the info in this `NetworkInfo` pertains.

<br />

| Returns ||
|---|---|
| `int` | one of `https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_MOBILE`, `https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_WIFI`, `https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_WIMAX`, `https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_ETHERNET`, `https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_BLUETOOTH`, or other types defined by `https://developer.android.com/reference/android/net/ConnectivityManager`. <br /> |

### getTypeName

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getTypeName ()
```

<br />

**This method was deprecated in API level 28.**   

Callers should switch to checking `https://developer.android.com/reference/android/net/NetworkCapabilities#hasTransport(int)` instead with one of the NetworkCapabilities#TRANSPORT_\* constants : `https://developer.android.com/reference/android/net/NetworkInfo#getType()` and `https://developer.android.com/reference/android/net/NetworkInfo#getTypeName()` cannot account for networks using multiple transports. Note that generally apps should not care about transport; `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_METERED` and `https://developer.android.com/reference/android/net/NetworkCapabilities#getLinkDownstreamBandwidthKbps()` are calls that apps concerned with meteredness or bandwidth should be looking at, as they offer this information with much better accuracy.

Return a human-readable name describe the type of the network, for example "WIFI" or "MOBILE".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the name of the network type <br /> |

### isAvailable

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isAvailable ()
```

<br />

**This method was deprecated in API level 28.**   

Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.

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

- 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.

Since Android L, this always returns `true`, because the system only returns info for available networks.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the network is available, `false` otherwise <br /> |

### isConnected

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isConnected ()
```

<br />

**This method is deprecated.**   

Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. See `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.

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

Always call this before attempting to perform data transactions.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if network connectivity exists, `false` otherwise. <br /> |

### isConnectedOrConnecting

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isConnectedOrConnecting ()
```

<br />

**This method was deprecated in API level 28.**   

Apps should instead use the `https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback` API to learn about connectivity changes. `https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)` and `https://developer.android.com/reference/android/net/ConnectivityManager#registerNetworkCallback(android.net.NetworkRequest,%20android.app.PendingIntent)`. These will give a more accurate picture of the connectivity state of the device and let apps react more easily and quickly to changes.

Indicates whether network connectivity exists or is in the process of being established. This is good for applications that need to do anything related to the network other than read or write data. For the latter, call `https://developer.android.com/reference/android/net/NetworkInfo#isConnected()` instead, which guarantees that the network is fully usable.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if network connectivity exists or is in the process of being established, `false` otherwise. <br /> |

### isFailover

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isFailover ()
```

<br />

**This method was deprecated in API level 28.**   

This field is not populated in recent Android releases, and does not make a lot of sense in a multi-network world.

Indicates whether the current attempt to connect to the network resulted from the ConnectivityManager trying to fail over to this network following a disconnect from another network.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if this is a failover attempt, `false` otherwise. <br /> |

### isRoaming

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isRoaming ()
```

<br />

**This method was deprecated in API level 28.**   

Callers should switch to checking `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_ROAMING` instead, since that handles more complex situations, such as VPNs.

Indicates whether the device is currently roaming on this network. When `true`, it suggests that use of data on this network may incur extra costs.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if roaming is in effect, `false` otherwise. <br /> |

### setDetailedState

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setDetailedState (NetworkInfo.DetailedState detailedState, 
                String reason, 
                String extraInfo)
```

<br />

**This method was deprecated in API level 29.**   

Use `https://developer.android.com/reference/android/net/NetworkCapabilities` instead.

Sets the fine-grained state of the network. This is only useful for testing.

<br />

| Parameters ||
|---|---|
| `detailedState` | `NetworkInfo.DetailedState`: the `https://developer.android.com/reference/android/net/NetworkInfo.DetailedState`. This value cannot be `null`. <br /> |
| `reason` | `String`: a `String` indicating the reason for the state change, if one was supplied. May be `null`. <br /> |
| `extraInfo` | `String`: an optional `String` providing additional network state information passed up from the lower networking layers. This value may be `null`. <br /> |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |