Added in API level 21

RouteInfo


class RouteInfo : Parcelable
kotlin.Any
   ↳ android.net.RouteInfo

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

Summary

Constants
static Int

Throw route.

static Int

Unicast route.

static Int

Unreachable route.

Inherited constants
Public methods
Int

Implement the Parcelable interface

Boolean
equals(other: Any?)

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

IpPrefix

Retrieves the destination address and prefix length in the form of an IpPrefix.

InetAddress?

Retrieves the gateway or next hop InetAddress for this route.

String?

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

Int

Retrieves the type of this route.

Boolean

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

Int

Returns a hashcode for this RouteInfo object.

Boolean

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

Boolean
matches(destination: InetAddress!)

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

String

Returns a human-readable description of this object.

Unit
writeToParcel(dest: Parcel, flags: Int)

Implement the Parcelable interface

Properties
static Parcelable.Creator<RouteInfo!>

Implement the Parcelable interface.

Constants

RTN_THROW

Added in API level 33
static val RTN_THROW: Int

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

Value: 9

RTN_UNICAST

Added in API level 33
static val RTN_UNICAST: Int

Unicast route. Indicates that destination is reachable directly or via gateway.

Value: 1

RTN_UNREACHABLE

Added in API level 33
static val RTN_UNREACHABLE: Int

Unreachable route. Indicates that destination is unreachable.

Value: 7

Public methods

describeContents

Added in API level 21
fun describeContents(): Int

Implement the Parcelable interface

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 21
fun equals(other: Any?): Boolean

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

Parameters
obj This value may be null.
Return
Boolean true if the objects are equal, false otherwise.

getDestination

Added in API level 21
fun getDestination(): IpPrefix

Retrieves the destination address and prefix length in the form of an IpPrefix.

Return
IpPrefix IpPrefix specifying the destination. This is never null.

getGateway

Added in API level 21
fun getGateway(): InetAddress?

Retrieves the gateway or next hop InetAddress for this route.

Return
InetAddress? InetAddress specifying the gateway or next hop. This may be null for a directly-connected route."

getInterface

Added in API level 21
fun getInterface(): String?

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

Return
String? The name of the interface used for this route.

getType

Added in API level 33
fun getType(): Int

Retrieves the type of this route.

Return
Int The type of this route; one of the RTN_xxx constants defined in this class. Value is android.net.RouteInfo#RTN_UNICAST, android.net.RouteInfo#RTN_UNREACHABLE, or android.net.RouteInfo#RTN_THROW

hasGateway

Added in API level 29
fun hasGateway(): Boolean

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

Return
Boolean true if a gateway is specified

hashCode

Added in API level 21
fun hashCode(): Int

Returns a hashcode for this RouteInfo object.

Return
Int a hash code value for this object.

isDefaultRoute

Added in API level 21
fun isDefaultRoute(): Boolean

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

Return
Boolean true if the destination has a prefix length of 0.

matches

Added in API level 21
fun matches(destination: InetAddress!): Boolean

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

Parameters
destination InetAddress!: A InetAddress to test to see if it would match this route.
Return
Boolean true if the destination and prefix length cover the given address.

toString

Added in API level 21
fun toString(): String

Returns a human-readable description of this object.

Return
String a string representation of the object.

writeToParcel

Added in API level 21
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Implement the Parcelable interface

Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 21
static val CREATOR: Parcelable.Creator<RouteInfo!>

Implement the Parcelable interface.