Introduction
The API operations provided by the Android software development kit (SDK) are categorized by feature as follows:
Configuration operations: SDK initialization, security settings, performance optimization, and network adaptation.
Domain name resolution operations: Synchronous, asynchronous, and non-blocking parsing, pre-parsing, and cache management.
Troubleshooting and tracing operations: Session tracing, Log Management, and debugging support.
Custom parsing operations: Synchronous, asynchronous, and non-blocking custom parsing.
Common data structures: Data structures for parsing results, callback functions, custom cache TTL, and domain name parsing filters.
The following classifications are based on the level of interface support:
Recommended operations: These operations are recommended for the current SDK version. They feature functional or user experience optimizations.
Deprecated operations: These operations are no longer recommended because of feature refactoring or design optimizations. Some operations may be removed in future versions. We recommend that you migrate to the corresponding recommended operations for better performance and stability.
This topic describes all API operations available in the HTTPDNS Android SDK to help you quickly understand and use the features of the SDK.
Interface configuration
Configuration operations are used to initialize and configure the features of the HTTPDNS SDK, such as service instance retrieval, cache policies, network parameters, and security settings. You can use these operations to customize the SDK's behavior based on your application's requirements and to optimize parsing performance and security.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDns | Gets an HTTPDNS service instance. | 2.6.3 | |
InitConfig.Builder | Sets the application context. | 2.6.3 | |
InitConfig.Builder | Sets the key to add a signature. | 2.6.3 | |
InitConfig.Builder | Sets the encryption key. | 2.6.3 | |
InitConfig.Builder | Specifies whether to enable the HTTPS protocol for communication with the server-side. | 2.2.2 | |
InitConfig.Builder | Specifies whether to allow returning expired IP addresses. | 2.2.2 | |
InitConfig.Builder | Allows the use of local cache that has expired for a period of time. | 2.4.3 | |
InitConfig.Builder | Enables the local cache feature. | 2.2.2 | |
InitConfig.Builder | Specifies whether to automatically refresh the local cache when the network changes. | 2.4.0 | |
InitConfig.Builder | Sets the threshold for the parsing timeout. | 2.4.0 | |
HttpDnsService | Corrects the signature time. | 1.3.2 | |
InitConfig.Builder | Sets the region node during initialization. | 2.4.2 | |
HttpDnsService | Updates the region node. | 2.4.2 | |
HttpDnsService | Updates the region node. | 2.4.2 | |
InitConfig.Builder | Customizes the cache duration for parsing results. | 2.3.0 | |
InitConfig.Builder | Sets a filter for domain names that do not use HTTPDNS for parsing. | 2.4.0 | |
InitConfig.Builder | Sets the domain names and probe ports for IP address optimization. | 2.3.2 | |
InitConfig.Builder | Sets global parameters for custom parsing. | 2.4.0 |
Deprecated Interfaces
Domain name resolution operations
Domain name resolution operations are a core feature of the HTTPDNS SDK. These operations provide multiple methods for domain name resolution, including synchronous, asynchronous, and non-blocking parsing. They support dual-stack resolution for IPv4 and IPv6, can automatically select the optimal resolution policy based on the network environment, and provide pre-parsing and cache management features.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDnsService | Sets a list of domain names for pre-parsing. | 2.4.0 | |
HttpDnsService | Parses a domain name synchronously and blocks the thread. | 2.3.2 | |
HttpDnsService | getHttpDnsResultForHostAsync(String, RequestIpType, HttpDnsCallback) | Parses a domain name asynchronously and returns the result through a callback. | 2.4.0 |
HttpDnsService | getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType) | Performs synchronous, non-blocking parsing. It only checks the cache. If the cache does not exist, it returns empty. | 2.4.0 |
HttpDnsService | Deletes the cache for a specified list of domain names. | 2.2.2 |
Deprecated operations
Troubleshooting and tracing operations
Troubleshooting and tracing operations are used for problem diagnosis and performance monitoring. They provide features such as session tracing and Log Management. You can use these operations to obtain detailed information about the parsing procedure. This information helps developers debug issues and allows operations and maintenance (O&M) engineers to troubleshoot problems, which improves application observability.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDnsService | Gets the session ID for the interaction with the HTTPDNS server in the current process. | 1.3.2 | |
HttpDnsLog | Controls the log output switch. | 2.0.2 | |
HttpDnsLog | Sets the log callback operation. | 2.0.2 | |
HttpDnsLog | Deletes the log callback class. | 2.0.2 |
Custom parsing interface
Custom parsing operations allow you to pass extra parameters for domain name resolution to meet the requirements of special business scenarios. You can use custom parameters to implement fine-grained parsing control, such as passing a business identity. This provides personalized parsing services for different business scenarios.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDnsService | getHttpDnsResultForHostSync(String, RequestIpType, Map<String, String>, String) | A synchronous parsing operation that lets you specify the parsing type. | 2.4.0 |
HttpDnsService | getHttpDnsResultForHostAsync(String, RequestIpType, Map<String, String>, String, HttpDnsCallback) | An asynchronous parsing operation that lets you specify the parsing type. | 2.4.0 |
HttpDnsService | getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType, Map<String, String>, String) | A synchronous, non-blocking operation that lets you specify the parsing type. | 2.4.0 |
Deprecated operations
Common data structure interfaces
This section defines the core data types and callback operations used in the SDK. These include data structures for parsing results, callback functions, filters, and configuration enumerations. These definitions provide a unified data model and interaction standard for all features of the SDK.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HTTPDNSResult | Gets the parsed domain name. | 1.3.2 | |
HTTPDNSResult | Gets the IPv4 address array. | 1.3.2 | |
HTTPDNSResult | Gets the IPv6 address array. | 2.0.2 | |
HTTPDNSResult | Gets the extra parameters returned by custom parsing. | 1.3.2 | |
HTTPDNSResult | Checks if the parsing result has expired. | 2.0.2 | |
HttpDnsCallback | The callback function for when parsing is complete. | 2.4.0 | |
CacheTtlChanger | The callback function for custom cache TTL. | 2.3.0 | |
NotUseHttpDnsFilter | The callback function for setting domain names that do not use HTTPDNS for parsing. | 2.4.0 | |
ILogger | Logging Interface | 1.3.2 | |
Region | - | The region enumeration type. | 2.4.2 |