Network
open class Network : Parcelable
| kotlin.Any | |
| ↳ | android.net.Network |
Identifies a Network. This is supplied to applications via ConnectivityManager.NetworkCallback in response to the active android.net.ConnectivityManager#requestNetwork or passive android.net.ConnectivityManager#registerNetworkCallback calls. It is used to direct traffic to the given Network, either on a Socket basis through a targeted SocketFactory or process-wide via ConnectivityManager.bindProcessToNetwork.
Summary
| Inherited constants | |
|---|---|
| Public methods | |
|---|---|
| open Unit |
bindSocket(fd: FileDescriptor!)Binds the specified |
| open Unit |
bindSocket(socket: DatagramSocket!)Binds the specified |
| open Unit |
bindSocket(socket: Socket!)Binds the specified |
| open Int | |
| open Boolean |
Indicates whether some other object is "equal to" this one. |
| open static Network! |
fromNetworkHandle(networkHandle: Long)Returns a |
| open Array<InetAddress!>! |
getAllByName(host: String!)Operates the same as |
| open InetAddress! |
Operates the same as |
| open Long |
Returns a handle representing this |
| open SocketFactory! |
Returns a |
| open Int |
hashCode() |
| open URLConnection! |
openConnection(url: URL!)Opens the specified |
| open URLConnection! |
openConnection(url: URL!, proxy: Proxy!)Opens the specified |
| open String |
toString() |
| open Unit |
writeToParcel(dest: Parcel, flags: Int) |
| Properties | |
|---|---|
| static Parcelable.Creator<Network!> | |
Public methods
bindSocket
open fun bindSocket(fd: FileDescriptor!): Unit
Binds the specified FileDescriptor to this Network. All data traffic on the socket represented by this file descriptor will be sent on this Network, irrespective of any process-wide network binding set by ConnectivityManager.bindProcessToNetwork. The socket must not be connected.
bindSocket
open fun bindSocket(socket: DatagramSocket!): Unit
Binds the specified DatagramSocket to this Network. All data traffic on the socket will be sent on this Network, irrespective of any process-wide network binding set by ConnectivityManager.bindProcessToNetwork. The socket must not be connected.
bindSocket
open fun bindSocket(socket: Socket!): Unit
Binds the specified Socket to this Network. All data traffic on the socket will be sent on this Network, irrespective of any process-wide network binding set by ConnectivityManager.bindProcessToNetwork. The socket must not be connected.
describeContents
open fun describeContents(): Int
| 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
open fun equals(other: Any?): Boolean
Indicates whether some other object is "equal to" this one.
The equals method implements an equivalence relation on non-null object references:
- It is reflexive: for any non-null reference value
x,x.equals(x)should returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| Parameters | |
|---|---|
obj |
This value may be null. |
| Return | |
|---|---|
Boolean |
true if this object is the same as the obj argument; false otherwise. |
fromNetworkHandle
open static fun fromNetworkHandle(networkHandle: Long): Network!
Returns a Network object given a handle returned from getNetworkHandle.
| Parameters | |
|---|---|
networkHandle |
Long: a handle returned from getNetworkHandle. |
| Return | |
|---|---|
Network! |
A Network object derived from networkHandle. |
getAllByName
open fun getAllByName(host: String!): Array<InetAddress!>!
Operates the same as InetAddress.getAllByName except that host resolution is done on this network.
| Parameters | |
|---|---|
host |
String!: the hostname or literal IP string to be resolved. |
| Return | |
|---|---|
Array<InetAddress!>! |
the array of addresses associated with the specified host. |
| Exceptions | |
|---|---|
java.net.UnknownHostException |
if the address lookup fails. |
getByName
open fun getByName(host: String!): InetAddress!
Operates the same as InetAddress.getByName except that host resolution is done on this network.
| Parameters | |
|---|---|
host |
String!: the hostname to be resolved to an address or null. |
| Return | |
|---|---|
InetAddress! |
the InetAddress instance representing the host. |
| Exceptions | |
|---|---|
java.net.UnknownHostException |
if the address lookup fails. |
getNetworkHandle
open fun getNetworkHandle(): Long
Returns a handle representing this Network, for use with the NDK API.
getSocketFactory
open fun getSocketFactory(): SocketFactory!
Returns a SocketFactory bound to this network. Any Socket created by this factory will have its traffic sent over this Network. Note that if this Network ever disconnects, this factory and any Socket it produced in the past or future will cease to work.
| Return | |
|---|---|
SocketFactory! |
a SocketFactory which produces Socket instances bound to this Network. |
hashCode
open fun hashCode(): Int
| Return | |
|---|---|
Int |
a hash code value for this object. |
openConnection
open fun openConnection(url: URL!): URLConnection!
Opens the specified URL on this Network, such that all traffic will be sent on this Network. The URL protocol must be HTTP or HTTPS.
| Return | |
|---|---|
URLConnection! |
a URLConnection to the resource referred to by this URL. |
| Exceptions | |
|---|---|
java.net.MalformedURLException |
if the URL protocol is not HTTP or HTTPS. |
java.io.IOException |
if an error occurs while opening the connection. |
See Also
openConnection
open fun openConnection(
url: URL!,
proxy: Proxy!
): URLConnection!
Opens the specified URL on this Network, such that all traffic will be sent on this Network. The URL protocol must be HTTP or HTTPS.
| Parameters | |
|---|---|
proxy |
Proxy!: the proxy through which the connection will be established. |
| Return | |
|---|---|
URLConnection! |
a URLConnection to the resource referred to by this URL. |
| Exceptions | |
|---|---|
java.net.MalformedURLException |
if the URL protocol is not HTTP or HTTPS. |
java.lang.IllegalArgumentException |
if the argument proxy is null. |
java.io.IOException |
if an error occurs while opening the connection. |
See Also
toString
open fun toString(): String
| Return | |
|---|---|
String |
a string representation of the object. |
writeToParcel
open fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
| 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 |