Class Components
Some of the configuration options in LDConfig.Builder affect the entire SDK, but others are
specific to one area of functionality, such as how the SDK receives feature flag updates or processes
analytics events. For the latter, the standard way to specify a configuration is to call one of the
static methods in Components, apply any desired configuration change to the object that that
method returns, and then use the corresponding method in LDConfig.Builder to use that
configured component in the SDK.
- Since:
- 3.3.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic ApplicationInfoBuilderReturns a configuration builder for the SDK's application metadata.static DataSystemBuilderReturns a builder for configuring the data system.static HooksConfigurationBuilderhooks()Returns a builder for configuring hooks.static HttpConfigurationBuilderReturns a configuration builder for the SDK's networking configuration.static ComponentConfigurer<EventProcessor>noEvents()Returns a configuration object that disables analytics events.static PluginsConfigurationBuilderplugins()Returns a builder for configuring plugins.static PollingDataSourceBuilderReturns a configuration builder for using polling mode to get feature flag data.static EventProcessorBuilderReturns a configuration builder for analytics event delivery.static ServiceEndpointsBuilderReturns a builder for configuring custom service URIs.static StreamingDataSourceBuilderReturns a configuration builder for using streaming mode to get feature flag data.
-
Method Details
-
applicationInfo
Returns a configuration builder for the SDK's application metadata.Passing this to
LDConfig.Builder.applicationInfo(com.launchdarkly.sdk.android.integrations.ApplicationInfoBuilder), after setting any desired properties on the builder, applies this configuration to the SDK.LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .applicationInfo( Components.applicationInfo() .applicationId("authentication-service") .applicationVersion("1.0.0") ) .build();- Returns:
- a builder object
- Since:
- 4.1.0
- See Also:
-
httpConfiguration
Returns a configuration builder for the SDK's networking configuration.Passing this to
LDConfig.Builder.http(ComponentConfigurer)applies this configuration to all HTTP/HTTPS requests made by the SDK.LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .http( Components.httpConfiguration() .connectTimeoutMillis(3000) .proxyHostAndPort("my-proxy", 8080) ) .build();- Returns:
- a factory object
- See Also:
-
noEvents
Returns a configuration object that disables analytics events.Passing this to
LDConfig.Builder.events(ComponentConfigurer)causes the SDK to discard all analytics events and not send them to LaunchDarkly, regardless of any other configuration.LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .events(Components.noEvents()) .build();- Returns:
- a configuration object
- See Also:
-
pollingDataSource
Returns a configuration builder for using polling mode to get feature flag data.By default, the SDK uses a streaming connection to receive feature flag data from LaunchDarkly. To use the default behavior, you do not need to call this method. However, if you want to customize the behavior of the connection, call this method to obtain a builder, change its properties with the
PollingDataSourceBuildermethods, and pass it toLDConfig.Builder.dataSource(ComponentConfigurer):LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .dataSource(Components.pollingDataSource().pollIntervalMillis(900_000)) .build();Setting
LDConfig.Builder.offline(boolean)totruewill supersede this setting and completely disable network requests.- Returns:
- a builder for setting polling connection properties
- See Also:
-
sendEvents
Returns a configuration builder for analytics event delivery.The default configuration has events enabled with default settings. If you want to customize this behavior, call this method to obtain a builder, change its properties with the
EventProcessorBuilderproperties, and pass it toLDConfig.Builder.events(ComponentConfigurer):
To completely disable sending analytics events, useLDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .events(Components.sendEvents().capacity(500).flushIntervalMillis(2000)) .build();noEvents()instead.Setting
LDConfig.Builder.offline(boolean)totruewill supersede this setting and completely disable network requests.- Returns:
- a builder for setting event-related options
- See Also:
-
serviceEndpoints
Returns a builder for configuring custom service URIs.Passing this to
LDConfig.Builder.serviceEndpoints(com.launchdarkly.sdk.android.integrations.ServiceEndpointsBuilder), after setting any desired properties on the builder, applies this configuration to the SDK.LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .serviceEndpoints( Components.serviceEndpoints() .relayProxy("http://my-relay-hostname:80") ) .build();- Returns:
- a builder object
- See Also:
-
streamingDataSource
Returns a configuration builder for using streaming mode to get feature flag data.By default, the SDK uses a streaming connection to receive feature flag data from LaunchDarkly. To use the default behavior, you do not need to call this method. However, if you want to customize the behavior of the connection, call this method to obtain a builder, change its properties with the
StreamingDataSourceBuildermethods, and pass it toLDConfig.Builder.dataSource(ComponentConfigurer):LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .dataSource(Components.streamingDataSource().initialReconnectDelayMillis(500)) .build();Setting
LDConfig.Builder.offline(boolean)totruewill supersede this setting and completely disable network requests.- Returns:
- a builder for setting streaming connection properties
- See Also:
-
hooks
Returns a builder for configuring hooks. Passing this toLDConfig.Builder.hooks(com.launchdarkly.sdk.android.integrations.HooksConfigurationBuilder), after setting any desired hooks on the builder, applies this configuration to the SDK.List hooks = myCreateHooksFunc(); LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .hooks( Components.hooks() .setHooks(hooks) ) .build();- Returns:
- a
HooksConfigurationBuilderthat can be used for customization
-
plugins
Returns a builder for configuring plugins. Passing this toLDConfig.Builder.plugins(com.launchdarkly.sdk.android.integrations.PluginsConfigurationBuilder), after setting any desired plugins on the builder, applies this configuration to the SDK.List plugins = getPluginsFunc(); LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .plugins( Components.plugins() .setPlugins(plugins) ) .build();- Returns:
- a
PluginsConfigurationBuilderfor plugins configuration
-
dataSystem
Returns a builder for configuring the data system.The data system controls how the SDK acquires and maintains feature flag data across different platform states (foreground, background, offline). It uses connection modes, each with its own pipeline of initializers and synchronizers.
When called with no further customization, the data system uses sensible defaults: streaming with polling fallback in the foreground and low-frequency polling in the background.
This class is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
Example — opting in to use the default data system:
LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .mobileKey("my-key") .dataSystem(Components.dataSystem()) .build();Example — customize background polling to once every 6 hours:
LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .mobileKey("my-key") .dataSystem( Components.dataSystem() .customizeConnectionMode(ConnectionMode.BACKGROUND, DataSystemComponents.customMode() .initializers(DataSystemComponents.pollingInitializer()) .synchronizers( DataSystemComponents.pollingSynchronizer() .pollIntervalMillis(21_600_000)))) .build();Example — use polling instead of streaming in the foreground:
LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .mobileKey("my-key") .dataSystem( Components.dataSystem() .foregroundConnectionMode(ConnectionMode.POLLING)) .build();Example — disable automatic mode switching:
LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .mobileKey("my-key") .dataSystem( Components.dataSystem() .automaticModeSwitching(AutomaticModeSwitchingConfig.disabled()) .foregroundConnectionMode(ConnectionMode.STREAMING)) .build();Example — disable lifecycle switching but keep network switching:
LDConfig config = new LDConfig.Builder(AutoEnvAttributes.Enabled) .mobileKey("my-key") .dataSystem( Components.dataSystem() .automaticModeSwitching( DataSystemComponents.automaticModeSwitching() .lifecycle(false) .network(true) .build())) .build();Setting
LDConfig.Builder.dataSystem(DataSystemBuilder)is mutually exclusive withLDConfig.Builder.dataSource(ComponentConfigurer). The data system uses the FDv2 protocol, whiledataSource()uses the legacy FDv1 protocol.- Returns:
- a builder for configuring the data system
- See Also:
-