Stay organized with collections
Save and categorize content based on your preferences.
Proxy
class Proxy
A convenience class for accessing the user and default proxy settings.
Summary
Constants |
static String |
Used to notify an app that's caching the proxy that either the default connection has changed or any connection's proxy has changed.
|
Public methods |
static String! |
Return the default proxy host specified by the carrier.
|
static Int |
Return the default proxy port specified by the carrier.
|
static String! |
Return the proxy host set by the user.
|
static Int |
Return the proxy port set by the user.
|
Constants
PROXY_CHANGE_ACTION
static val PROXY_CHANGE_ACTION: String
Used to notify an app that's caching the proxy that either the default connection has changed or any connection's proxy has changed. The new proxy should be queried using ConnectivityManager.getDefaultProxy()
.
This is a protected intent that can only be sent by the system
Value: "android.intent.action.PROXY_CHANGE"
Public constructors
Public methods
getDefaultHost
static fun getDefaultHost(): String!
Deprecated: Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list and no longer reports only mobile-data apn-based proxy values.
Return the default proxy host specified by the carrier.
Return |
String! |
String containing the host name or null if there is no proxy for this carrier. |
getDefaultPort
static fun getDefaultPort(): Int
Deprecated: Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list and no longer reports only mobile-data apn-based proxy values.
Return the default proxy port specified by the carrier.
Return |
Int |
The port number to be used with the proxy host or -1 if there is no proxy for this carrier. |
getHost
static fun getHost(ctx: Context!): String!
Deprecated: Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list.
Return the proxy host set by the user.
Parameters |
ctx |
Context!: A Context used to get the settings for the proxy host. |
Return |
String! |
String containing the host name. If the user did not set a host name it returns the default host. A null value means that no host is to be used. |
getPort
static fun getPort(ctx: Context!): Int
Deprecated: Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list.
Return the proxy port set by the user.
Parameters |
ctx |
Context!: A Context used to get the settings for the proxy port. |
Return |
Int |
The port number to use or -1 if no proxy is to be used. |
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 2025-02-10 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 2025-02-10 UTC."],[],[],null,["# Proxy\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nProxy\n=====\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/Proxy \"View this page in Java\") \n\n```\nclass Proxy\n```\n\n|---|------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.net.Proxy](#) |\n\nA convenience class for accessing the user and default proxy settings.\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [PROXY_CHANGE_ACTION](#PROXY_CHANGE_ACTION:kotlin.String) Used to notify an app that's caching the proxy that either the default connection has changed or any connection's proxy has changed. |\n\n| Public constructors ||\n|------------------------------|---|\n| [Proxy](#Proxy())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| static [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getDefaultHost](#getDefaultHost())`()` Return the default proxy host specified by the carrier. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getDefaultPort](#getDefaultPort())`()` Return the default proxy port specified by the carrier. |\n| static [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getHost](#getHost(android.content.Context))`(`ctx:` `[Context](../content/Context.html#)!`)` Return the proxy host set by the user. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getPort](#getPort(android.content.Context))`(`ctx:` `[Context](../content/Context.html#)!`)` Return the proxy port set by the user. |\n\nConstants\n---------\n\n### PROXY_CHANGE_ACTION\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val PROXY_CHANGE_ACTION: String\n```\n\nUsed to notify an app that's caching the proxy that either the default connection has changed or any connection's proxy has changed. The new proxy should be queried using [ConnectivityManager.getDefaultProxy()](/reference/kotlin/android/net/ConnectivityManager#getDefaultProxy()).\n\nThis is a protected intent that can only be sent by the system \n\n Value: \"android.intent.action.PROXY_CHANGE\"\n\nPublic constructors\n-------------------\n\n### Proxy\n\n```\nProxy()\n```\n\nPublic methods\n--------------\n\n### getDefaultHost\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic fun getDefaultHost(): String!\n```\n\n**Deprecated:** *Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list and no longer reports only mobile-data apn-based proxy values.*\n\nReturn the default proxy host specified by the carrier.\n\n| Return ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | String containing the host name or null if there is no proxy for this carrier. |\n\n### getDefaultPort\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic fun getDefaultPort(): Int\n```\n\n**Deprecated:** *Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list and no longer reports only mobile-data apn-based proxy values.*\n\nReturn the default proxy port specified by the carrier.\n\n| Return ||\n|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The port number to be used with the proxy host or -1 if there is no proxy for this carrier. |\n\n### getHost\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic fun getHost(ctx: Context!): String!\n```\n\n**Deprecated:** *Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list.*\n\nReturn the proxy host set by the user.\n\n| Parameters ||\n|-------|----------------------------------------------------------------------------------------------|\n| `ctx` | [Context](../content/Context.html#)!: A Context used to get the settings for the proxy host. |\n\n| Return ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | String containing the host name. If the user did not set a host name it returns the default host. A null value means that no host is to be used. |\n\n### getPort\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic fun getPort(ctx: Context!): Int\n```\n\n**Deprecated:** *Use standard java vm proxy values to find the host, port and exclusion list. This call ignores the exclusion list.*\n\nReturn the proxy port set by the user.\n\n| Parameters ||\n|-------|----------------------------------------------------------------------------------------------|\n| `ctx` | [Context](../content/Context.html#)!: A Context used to get the settings for the proxy port. |\n\n| Return ||\n|----------------------------------------------------------------------------|---------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The port number to use or -1 if no proxy is to be used. |"]]