Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

ProxyConfig

class ProxyConfig
kotlin.Any
   ↳ androidx.webkit.ProxyConfig

Config for ProxyController#setProxyOverride(ProxyConfig, Executor, Runnable).

Proxy rules should be added using addProxyRule methods. Multiple rules can be used as fallback if a proxy fails to respond (for example, the proxy server is down). Bypass rules can be set for URLs that should not use these settings.

For instance, the following code means that WebView would first try to use proxy1.com for all URLs, if that fails, proxy2.com, and if that fails, it would make a direct connection.

ProxyConfig proxyConfig = new ProxyConfig.Builder().addProxyRule("proxy1.com")
                                                     .addProxyRule("proxy2.com")
                                                     .addDirect()
                                                     .build();
  

Summary

Nested classes

ProxyConfig builder.

Class that holds a scheme filter and a proxy URL.

Constants

static String

Matches all schemes.

static String

HTTP scheme.

static String

HTTPS scheme.

Public methods

MutableList<String!>

Returns the current list that holds the bypass rules represented by this object.

MutableList<ProxyConfig.ProxyRule!>

Returns the current list of proxy rules.

Constants

MATCH_ALL_SCHEMES

static val MATCH_ALL_SCHEMES: String

Matches all schemes.

Value: "*"

MATCH_HTTP

static val MATCH_HTTP: String

HTTP scheme.

Value: "http"

MATCH_HTTPS

static val MATCH_HTTPS: String

HTTPS scheme.

Value: "https"

Public methods

getBypassRules

@NonNull fun getBypassRules(): MutableList<String!>

Returns the current list that holds the bypass rules represented by this object.

To add new rules use Builder#addBypassRule(String).

Return
MutableList<String!>: List of bypass rules

getProxyRules

@NonNull fun getProxyRules(): MutableList<ProxyConfig.ProxyRule!>

Returns the current list of proxy rules. Each ProxyRule object holds the proxy URL and the URL schemes for which this proxy is used (one of MATCH_HTTP, MATCH_HTTPS, MATCH_ALL_SCHEMES).

To add new rules use Builder#addProxyRule(String) or Builder#addProxyRule(String, String).

Return
MutableList<ProxyConfig.ProxyRule!>: List of proxy rules