[ Web Proxy ]
URL:
Viewing: https://developer.android.com/reference/android/net/http/ProxyOptions [Back]  [Original]

ProxyOptions  |  API reference  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]
Stay organized with collections Save and categorize content based on your preferences.

ProxyOptions


public final class ProxyOptions
extends Object

java.lang.Object
   ↳ android.net.http.ProxyOptions


Defines a proxy configuration that can be used by HttpEngine.

Summary

Constants

int ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT

Allows direct, non-proxied, traffic.

int ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT

Disallows direct traffic.

Public methods

static ProxyOptions ,%20int)">fromProxyList(List<Proxy> proxyList, int allProxiesFailedBehavior)

Constructs a proxy configuration out of a list of Proxy.

Inherited methods

Constants

ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT

Added in API level 37
Also in S Extensions 22
public static final int ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT

Allows direct, non-proxied, traffic.

This defines a fail-open behavior: if all proxies in a ProxyOptions have failed, HttpEngine will fall back onto non-proxied connections.

Constant Value: 1 (0x00000001)

ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT

Added in API level 37
Also in S Extensions 22
public static final int ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT

Disallows direct traffic.

This defines a fail-closed behavior: if all proxies in a ProxyOptions have failed, HttpEngine won't fall back onto non-proxied connections.

Constant Value: 0 (0x00000000)

Public methods

fromProxyList

Added in API level 37
Also in S Extensions 22
public static ProxyOptions fromProxyList (List<Proxy> proxyList, 
                int allProxiesFailedBehavior)

Constructs a proxy configuration out of a list of Proxy.

Proxies in the list will be used in order. Proxy in position N+1 will be used only if HttpEngine failed to use proxy in position N. If proxy in position N fails, for any reason (including tunnel closures triggered via Proxy.HttpConnectCallback), but proxy in position N+1 succeeds, proxies in position N will be temporarily deprioritized. While a proxy is deprioritized it will be used only as a last resort.

Parameters
proxyList List: The list of Proxy that defines this configuration.
This value cannot be null.

allProxiesFailedBehavior int: How HttpEngine must behave after it has failed to use all proxies in proxyList.
Value is one of the following:
Returns
ProxyOptions This value cannot be null.

Throws
IllegalArgumentException If the proxy list is empty, or any element is null.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-08-03 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-03 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page