Android

circle-info

Hackle Android SDK supports Android API 16 and above (4.1 Jelly Bean).

Add Dependency

arrow-up-right

repositories {
  mavenCentral()
}

Add the dependency to your build.gradle file.

dependencies {
  implementation 'io.hackle:hackle-android-sdk:2.66.1'
}

ProGuard

If you use ProGuard, obfuscation rules are automatically included in the aar artifact. Otherwise, you must include the rules below.

-keep class io.hackle.android.** { *; }
-keep class io.hackle.sdk.** { *; }

Third-party Dependencies

The Hackle Android SDK has the following third-party dependencies.

Library
Description

com.squareup.okhttp3:okhttp:3.12.2

HTTP/HTTPS client

com.google.code.gson:gson:2.8.6

JSON serialization/deserialization

com.google.android.gms:play-services-base:17.3.0

Google Play Services common module

SDK Initialization

You must initialize HackleApp before using the SDK.

  • An SDK Key is required to initialize HackleApp.

  • HackleApp is the class that provides methods for using SDK features.

  • You can find the SDK Key in SDK Integration Infoarrow-up-right on the Hackle Dashboard.

Initialization runs asynchronously, fetching the necessary information from the Hackle server and storing it in the SDK.

circle-exclamation

Display a splash screen instead of immediately launching the app, and initialize the SDK. After initialization, close the splash screen via callback so the user can begin interacting with the app.

Inject User on Initialization

You can initialize the SDK with user information included.

  • If no user information is provided, the user information stored in local storage is used.

  • If user information is provided, the user information stored in local storage is not used.

  • If no user is injected and there is no user information in local storage, a user with the Hackle Device ID as the device ID is used.

circle-info

User information can be freely updated after SDK initialization using the user configuration functions.

circle-exclamation

SDK Initialization Config

You can initialize the SDK with a configuration object.

Configuration Options

Option
Description
Default
Min Version

exposureEventDedupIntervalMillis*

Removes duplicate exposure events for the same A/B Test or Feature Flag result triggered consecutively by the same user.

  • Min: 1000 (1 second)

  • Max: 86400000 (24 hours)

60000 (1 min)

2.7.0+

eventFlushIntervalMillis

The interval at which collected events are sent to the server.

  • Min: 1000 (1 second)

  • Max: 60000 (1 minute)

10000 (10 sec)

2.10.0+

pollingIntervalMillis

Periodically updates configuration set in the Dashboard.

  • Min: 60000 (60 seconds)

-1 (no periodic update)

2.19.0+

automaticScreenTracking

Whether to enable automatic Screen Tracking

true

2.39.0+

automaticAppLifecycleTracking

Whether to enable automatic app start/stop tracking

true

2.64.0+

sessionPolicy

Configures session persistence and expiration conditions.

ALWAYS_NEW_SESSION ,

1800000

2.65.0+

optOutTracking

Whether to enable Opt-out.

false

2.65.0+

sessionTimeoutMillis (deprecated)

Sets the session timeout duration. Use sessionPolicy instead.

1800000 (30 min)

2.13.0+

* Supported even after app restart from version 2.47.0. * For versions below 2.47.0, the maximum value is: 3600000 (1 hour).

Session Policy Configuration

You can configure session persistence and expiration conditions using the session policy.

Get Instance

After initialization, you can retrieve the HackleApp instance with the code below.

Refresh Dashboard Configuration

After initialization, you can explicitly refresh Dashboard configuration when needed.

circle-exclamation

Last updated