Introduction
The APIs provided by the Android software development kit (SDK) can be categorized by feature as follows:
Configuration APIs: SDK initialization, security settings, performance optimization, and network adaptation.
Domain name resolution APIs: Synchronous, asynchronous, and non-blocking resolution, pre-resolution, and cache management.
Troubleshooting and tracing APIs: Session tracing, log management, and debugging support.
Custom resolution APIs: Synchronous, asynchronous, and non-blocking APIs for custom resolution.
Common data structure APIs: Resolution results, callback functions, custom cache TTL, and domain name resolution filters.
The APIs are also categorized based on their support level:
Recommended APIs: These APIs are recommended for the current SDK version. They are optimized for functionality or user experience.
Deprecated APIs: These APIs are no longer recommended due to feature refactoring or design optimization. Some of these APIs may be removed in future versions. Migrate to the corresponding recommended APIs for better performance and stability.
This topic describes all APIs in the HTTPDNS Android SDK and helps you quickly understand and use the features of the SDK.
Configuration APIs
Configuration APIs are used to initialize and configure the features of the HTTPDNS SDK. These features include service instance acquisition, cache policies, network parameters, and security settings. Use these APIs to customize the SDK's behavior and optimize resolution performance and security based on your application's needs.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDns | Get an HTTPDNS service instance | 2.6.3 | |
InitConfig.Builder | Set the application context | 2.6.3 | |
InitConfig.Builder | Set the signing key | 2.6.3 | |
InitConfig.Builder | Set the encryption key | 2.6.3 | |
InitConfig.Builder | Specify whether to use the HTTPS protocol to communicate with the server | 2.2.2 | |
InitConfig.Builder | Specify whether to allow returning expired IP addresses | 2.2.2 | |
InitConfig.Builder | Allow the use of local cache that has expired for a period of time | 2.4.3 | |
InitConfig.Builder | Enable the local cache feature | 2.2.2 | |
InitConfig.Builder | Specify whether to automatically refresh the local cache when the network changes | 2.4.0 | |
InitConfig.Builder | Set the resolution timeout threshold | 2.4.0 | |
HttpDnsService | Correct the signing time | 1.3.2 | |
InitConfig.Builder | Set the region node during initialization | 2.4.2 | |
HttpDnsService | Update the region node | 2.4.2 | |
HttpDnsService | Update the region node | 2.4.2 | |
InitConfig.Builder | Customize the cache duration for resolution results | 2.3.0 | |
InitConfig.Builder | Set a filter for domain names that do not use HTTPDNS for resolution | 2.4.0 | |
InitConfig.Builder | Set the domain names and probing ports for IP address selection | 2.3.2 | |
InitConfig.Builder | Set global parameters for custom resolution | 2.4.0 |
Deprecated APIs
Domain name resolution APIs
Domain name resolution APIs are a core feature of the HTTPDNS SDK. They provide multiple resolution methods, including synchronous, asynchronous, and non-blocking resolution. The SDK supports dual-stack resolution for IPv4 and IPv6. It automatically selects the optimal resolution policy based on the network environment. It also provides pre-resolution and cache management features.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDnsService | Set the list of domain names for pre-resolution | 2.4.0 | |
HttpDnsService | Resolve a domain name synchronously. This blocks the thread. | 2.3.2 | |
HttpDnsService | getHttpDnsResultForHostAsync(String, RequestIpType, HttpDnsCallback) | Resolve a domain name asynchronously. The result is returned through a callback. | 2.4.0 |
HttpDnsService | getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType) | Perform synchronous, non-blocking resolution. This only checks the cache. If the cache does not exist, it returns empty. | 2.4.0 |
HttpDnsService | Clear the cache for a specified list of domain names. | 2.2.2 |
Deprecated APIs
Troubleshooting and tracing APIs
Troubleshooting and tracing APIs are used for problem diagnosis and performance monitoring. They provide features such as session tracing and log management. Use these APIs to obtain detailed information about the resolution process. This information helps developers with debugging and O&M engineers with troubleshooting, which improves application observability.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDnsService | Get the session ID for the interaction with the HTTPDNS server in the current process | 1.3.2 | |
HttpDnsLog | Control the log output switch | 2.0.2 | |
HttpDnsLog | Set a log callback interface | 2.0.2 | |
HttpDnsLog | Delete a log callback class | 2.0.2 |
Custom resolution APIs
Custom resolution APIs support passing extra parameters for domain name resolution to address specific business requirements. Use custom parameters to achieve fine-grained resolution control, such as passing business identities. This provides personalized resolution services for different scenarios.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HttpDnsService | getHttpDnsResultForHostSync(String, RequestIpType, Map<String, String>, String) | A synchronous API that lets you specify the resolution type | 2.4.0 |
HttpDnsService | getHttpDnsResultForHostAsync(String, RequestIpType, Map<String, String>, String, HttpDnsCallback) | An asynchronous API that lets you specify the resolution type | 2.4.0 |
HttpDnsService | getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType, Map<String, String>, String) | A synchronous, non-blocking API that lets you specify the resolution type | 2.4.0 |
Deprecated APIs
Common data structure APIs
Common data structure APIs define the core data types and callback interfaces used in the SDK. These include resolution result encapsulation, callback functions, filters, and configuration enumerations. These APIs provide a unified data model and interaction standard for all SDK features.
Recommended APIs
Class | Function declaration | Description | Introduced in version |
HTTPDNSResult | Get the resolved domain name | 1.3.2 | |
HTTPDNSResult | Get the array of IPv4 addresses | 1.3.2 | |
HTTPDNSResult | Get the array of IPv6 addresses | 2.0.2 | |
HTTPDNSResult | Get the extra parameters returned from custom resolution | 1.3.2 | |
HTTPDNSResult | Check if the resolution result has expired | 2.0.2 | |
HttpDnsCallback | Callback function for when resolution is complete | 2.4.0 | |
CacheTtlChanger | Callback function to customize the cache TTL | 2.3.0 | |
NotUseHttpDnsFilter | Callback function to set domain names that do not use HTTPDNS for resolution | 2.4.0 | |
ILogger | Log output API | 1.3.2 | |
Region | - | Region enumeration type | 2.4.2 |