# 1. Android Checklist

{% hint style="danger" %}
This document refers to deprecated parts of the platform and has been left intact to help customers with legacy integrations. In order to access the latest platform features and documentation, please go to <https://docs.sentiance.com>.
{% endhint %}

Follow the step below to integrate the Android SDK.

### 1. Installation

<details>

<summary>1.1 Dependency</summary>

Add the Sentiance repository to your project (top-level) *build.gradle* file.

```
allprojects {
  repositories {
    ...
    maven {
      url "https://repository.sentiance.com"
    }
  }
}
```

In the *build.gradle* file of your app module, add the following line to the dependencies section.

```
implementation ('com.sentiance:sdk:4.21.2@aar') { transitive = true }
```

</details>

### 2. Configuration

<details>

<summary>2.2 Notification &#x26; Foreground Service</summary>

Depending on your app's configuration and OS version, the SDK may need to start a foreground service every now and again. You must therefore pass a notification that can be used by the service. In the next section, you'll find a handy notification creation method.

Learn more on how to easily setup a [sample notification](https://docs.sentiance.com/sdk/appendix/android/notification-management)

</details>

### 3. Usage

<details>

<summary>3.1 SentianceHelper.kt</summary>

For a quick start we have created helper file a couple of methods to easily get started. [Download this file](https://github.com/sentiance/sample-apps-android/blob/main/app/src/main/java/com/example/sentiancesdksample_app_android/helpers/SentianceHelper.kt) and place it anywhere accessible in your codebase.

</details>

<details>

<summary>3.2 Initialization &#x26; Background Collection</summary>

Insert the following line in the *onCreate* method of your MainApplication.kt file\_.\_ This line ensures that the SDK is initialized and can collect data while the application is in the background.

```
# MainApplication.kt

SentianceHelper().initSdk(applicationContext, null)
```

[See reference](https://github.com/sentiance/sample-apps-android/blob/main/app/src/main/java/com/example/sentiancesdksample_app_android/MainApplication.kt#L14)

</details>

### 4. Data Collection & SDK User Creation

In order for the SDK to collect data the application would need to first "create a user" on the SDK. The "createUser" should ideally be called when the user registers, logs in.

<details>

<summary>4.1 createUser</summary>

Invoke the *SentianceHelper().createUser* method at the moment you are ready to start the data collection. (e.g on user login, on user registration, at a feature, etc)

```swift
SentianceHelper.createUser(SDKParams(
   appId,
   secret,
   null,
   link,
   callback
))
```

[See reference](https://github.com/sentiance/sample-apps-android/blob/main/app/src/main/java/com/example/sentiancesdksample_app_android/MainActivity.kt#L39)

</details>

<details>

<summary>4.2 link</summary>

This method will receive the parameters: `installId, MetaUserLinkerCallback`

[See reference](https://github.com/sentiance/sample-apps-android/blob/main/app/src/main/java/com/example/sentiancesdksample_app_android/MainActivity.kt#L51)

</details>

<details>

<summary>4.3 User linking in your backend</summary>

In the `link` function, at this point, make your backend tell the Sentiance backend which `userId` should be related to the `installId`

[See reference](https://github.com/sentiance/sample-apps-api/blob/master/src/routes.js#L61)

</details>

<details>

<summary>4.3 metaUserLinkerCallback.success()</summary>

Upon your backend successfully performing the user linking execute the

```
metaUserLinkerCallback.success()
```

</details>

### Verifying the Integration

You can verify the SDK integration by reading the following statuses from the SDK

| Sentiance.getInstance().getInitState()             | **INITIALIZED** |
| -------------------------------------------------- | --------------- |
| Sentiance.getInstance().getSdkStatus().startStatus | **STARTED**     |

*Note: If you find the **startStatus** to be **PENDING** it usually implies that the user has not granted **location:always** permission. To know more,* [*click here*](https://docs.sentiance.com/sdk/api-reference/android/sdkstatus/startstatus)\_\_

You can continue reading through the next sections to get a deeper understanding of the integration and the SDK capabilities.
