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

# RouteInfo

*** ** * ** ***


`
public

final

class
RouteInfo
`


`

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

<br />

*** ** * ** ***

Represents a network route.


This is used both to describe static network configuration and live network
configuration information.

A route contains three pieces of information:

- a destination `https://developer.android.com/reference/android/net/IpPrefix` specifying the network destinations covered by this route. If this is `null` it indicates a default route of the address family (IPv4 or IPv6) implied by the gateway IP address.
- a gateway `https://developer.android.com/reference/java/net/InetAddress` indicating the next hop to use. If this is `null` it indicates a directly-connected route.
- an interface (which may be unspecified).

Either the destination or the gateway may be `null`, but not both. If the destination and gateway are both specified, they must be of the same address family (IPv4 or IPv6).

<br />

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/net/RouteInfo#RTN_THROW` Throw route. |
| `int` | `https://developer.android.com/reference/android/net/RouteInfo#RTN_UNICAST` Unicast route. |
| `int` | `https://developer.android.com/reference/android/net/RouteInfo#RTN_UNREACHABLE` Unreachable route. |

| ### 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/RouteInfo>` | `https://developer.android.com/reference/android/net/RouteInfo#CREATOR` Implement the Parcelable interface. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/net/RouteInfo#describeContents()() ` Implement the Parcelable interface |
| ` boolean` | ` https://developer.android.com/reference/android/net/RouteInfo#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Compares this RouteInfo object against the specified object and indicates if they are equal. |
| ` https://developer.android.com/reference/android/net/IpPrefix` | ` https://developer.android.com/reference/android/net/RouteInfo#getDestination()() ` Retrieves the destination address and prefix length in the form of an `https://developer.android.com/reference/android/net/IpPrefix`. |
| ` https://developer.android.com/reference/java/net/InetAddress` | ` https://developer.android.com/reference/android/net/RouteInfo#getGateway()() ` Retrieves the gateway or next hop `https://developer.android.com/reference/java/net/InetAddress` for this route. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/RouteInfo#getInterface()() ` Retrieves the interface used for this route if specified, else `null`. |
| ` int` | ` https://developer.android.com/reference/android/net/RouteInfo#getType()() ` Retrieves the type of this route. |
| ` boolean` | ` https://developer.android.com/reference/android/net/RouteInfo#hasGateway()() ` Indicates if this route has a next hop (`true`) or is directly-connected (`false`). |
| ` int` | ` https://developer.android.com/reference/android/net/RouteInfo#hashCode()() ` Returns a hashcode for this `RouteInfo` object. |
| ` boolean` | ` https://developer.android.com/reference/android/net/RouteInfo#isDefaultRoute()() ` Indicates if this route is a default route (ie, has no destination specified). |
| ` boolean` | ` https://developer.android.com/reference/android/net/RouteInfo#matches(java.net.InetAddress)(https://developer.android.com/reference/java/net/InetAddress destination) ` Determines whether the destination and prefix of this route includes the specified address. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/RouteInfo#toString()() ` Returns a human-readable description of this object. |
| ` void` | ` https://developer.android.com/reference/android/net/RouteInfo#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Implement the Parcelable interface |

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

## Constants

### RTN_THROW

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

```
public static final int RTN_THROW
```

Throw route.

Indicates that routing information about this destination is not in this table.
Routing lookup should continue in another table.

<br />

Constant Value:

9
(0x00000009)


### RTN_UNICAST

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

```
public static final int RTN_UNICAST
```

Unicast route.

Indicates that destination is reachable directly or via gateway.

<br />

Constant Value:

1
(0x00000001)


### RTN_UNREACHABLE

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

```
public static final int RTN_UNREACHABLE
```

Unreachable route.

Indicates that destination is unreachable.

<br />

Constant Value:

7
(0x00000007)


## Fields

### CREATOR

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

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

Implement the Parcelable interface.

<br />

## Public methods

### describeContents

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

```
public int describeContents ()
```

Implement the Parcelable interface

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

### equals

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

```
public boolean equals (Object obj)
```

Compares this RouteInfo object against the specified object and indicates if they are equal.

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the objects are equal, `false` otherwise. <br /> |

### getDestination

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

```
public IpPrefix getDestination ()
```

Retrieves the destination address and prefix length in the form of an `https://developer.android.com/reference/android/net/IpPrefix`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/IpPrefix` | `https://developer.android.com/reference/android/net/IpPrefix` specifying the destination. This is never `null`. <br /> |

### getGateway

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

```
public InetAddress getGateway ()
```

Retrieves the gateway or next hop `https://developer.android.com/reference/java/net/InetAddress` for this route.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/net/InetAddress` | `https://developer.android.com/reference/java/net/InetAddress` specifying the gateway or next hop. This may be `null` for a directly-connected route." <br /> |

### getInterface

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

```
public String getInterface ()
```

Retrieves the interface used for this route if specified, else `null`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | The name of the interface used for this route. <br /> |

### getType

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

```
public int getType ()
```

Retrieves the type of this route.

<br />

| Returns ||
|---|---|
| `int` | The type of this route; one of the `RTN_xxx` constants defined in this class. Value is one of the following: - `https://developer.android.com/reference/android/net/RouteInfo#RTN_UNICAST` - `https://developer.android.com/reference/android/net/RouteInfo#RTN_UNREACHABLE` - `https://developer.android.com/reference/android/net/RouteInfo#RTN_THROW` |

### hasGateway

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

```
public boolean hasGateway ()
```

Indicates if this route has a next hop (`true`) or is directly-connected
(`false`).

<br />

| Returns ||
|---|---|
| `boolean` | `true` if a gateway is specified <br /> |

### hashCode

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

```
public int hashCode ()
```

Returns a hashcode for this `RouteInfo` object.

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### isDefaultRoute

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

```
public boolean isDefaultRoute ()
```

Indicates if this route is a default route (ie, has no destination specified).

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the destination has a prefix length of 0. <br /> |

### matches

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

```
public boolean matches (InetAddress destination)
```

Determines whether the destination and prefix of this route includes the specified
address.

<br />

| Parameters ||
|---|---|
| `destination` | `InetAddress`: A `https://developer.android.com/reference/java/net/InetAddress` to test to see if it would match this route. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the destination and prefix length cover the given address. <br /> |

### toString

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

```
public String toString ()
```

Returns a human-readable description of this object.

<br />

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

### writeToParcel

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

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

Implement the Parcelable interface

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