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

# Proxy


`
public


class
Proxy
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

This class represents a proxy setting, typically a type (http, socks) and
a socket address.
A `Proxy` is an immutable object.
**See also:**

- `https://developer.android.com/reference/java/net/ProxySelector`

## Summary

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/java/net/Proxy` | `https://developer.android.com/reference/java/net/Proxy#NO_PROXY` A proxy setting that represents a `DIRECT` connection, basically telling the protocol handler not to use any proxying. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/net/Proxy#Proxy(java.net.Proxy.Type,%20java.net.SocketAddress)(https://developer.android.com/reference/java/net/Proxy.Type type, https://developer.android.com/reference/java/net/SocketAddress sa) ` Creates an entry representing a PROXY connection. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/net/SocketAddress` | ` https://developer.android.com/reference/java/net/Proxy#address()() ` Returns the socket address of the proxy, or `null` if its a direct connection. |
| ` final boolean` | ` https://developer.android.com/reference/java/net/Proxy#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Compares this object against the specified object. |
| ` final int` | ` https://developer.android.com/reference/java/net/Proxy#hashCode()() ` Returns a hashcode for this Proxy. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/net/Proxy#toString()() ` Constructs a string representation of this Proxy. |
| ` https://developer.android.com/reference/java/net/Proxy.Type` | ` https://developer.android.com/reference/java/net/Proxy#type()() ` Returns the proxy type. |

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

## Fields

### NO_PROXY

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

```
public static final Proxy NO_PROXY
```

A proxy setting that represents a `DIRECT` connection,
basically telling the protocol handler not to use any proxying.
Used, for instance, to create sockets bypassing any other global
proxy settings (like SOCKS):


`Socket s = new Socket(Proxy.NO_PROXY);`

<br />

## Public constructors

### Proxy

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

```
public Proxy (Proxy.Type type, 
                SocketAddress sa)
```

Creates an entry representing a PROXY connection.
Certain combinations are illegal. For instance, for types Http, and
Socks, a SocketAddress **must** be provided.


Use the `Proxy.NO_PROXY` constant
for representing a direct connection.

<br />

| Parameters ||
|---|---|
| `type` | `Proxy.Type`: the `Type` of the proxy <br /> |
| `sa` | `SocketAddress`: the `SocketAddress` for that proxy <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when the type and the address are incompatible |

## Public methods

### address

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

```
public SocketAddress address ()
```

Returns the socket address of the proxy, or
`null` if its a direct connection.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/net/SocketAddress` | a `SocketAddress` representing the socket end point of the proxy <br /> |

### equals

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

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

Compares this object against the specified object.
The result is `true` if and only if the argument is
not `null` and it represents the same proxy as
this object.


Two instances of `Proxy` represent the same
address if both the SocketAddresses and type are equal.

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: the object to compare against. <br /> |

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

**See also:**

- `https://developer.android.com/reference/java/net/InetSocketAddress#equals(java.lang.Object)`

### hashCode

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

```
public final int hashCode ()
```

Returns a hashcode for this Proxy.

<br />

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

### toString

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

```
public String toString ()
```

Constructs a string representation of this Proxy.
This String is constructed by calling toString() on its type
and concatenating " @ " and the toString() result from its address
if its type is not `DIRECT`.

<br />

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

### type

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

```
public Proxy.Type type ()
```

Returns the proxy type.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/net/Proxy.Type` | a Type representing the proxy type <br /> |