# Android SDK Integration Guide

## Overview

1. [Requirements](#requirements)
2. [Steps](#steps)
3. [Sample](#sample)

## Requirements

* API Level 18 or higher
* Kotlin

Please update to the latest SDK!

## Steps

1. [Downloads](#1-downloads)
2. [Get Credentials](#2-get-credentials)
3. [Configuration](#3-configuration)
4. [Using the SDK in Kotlin](#4-using-the-sdk-in-kotlin)
5. [Using the SDK in Java](#5-using-the-sdk-in-java)

### 1. Downloads

```bash
allprojects {
               repositories {
               ...
                   maven { url 'https://jitpack.io' }
               }
           }
           .
           .
           .
           dependencies {
               implementation 'com.github.human-internet:humanid-android-sdk:0.0.4’
           }
```

### 2. Get Credentials

Get the clientID and clientSecret through the [App Registration Form](https://developers.human-id.org/home/)

### 3. Configuration

Add this code to your AndroidManifest.xml. Make sure that all metadata is fulfilled.

```bash
<meta-data  
           android:name="com.humanid.sdk.applicationIcon"  
           android:resource="@drawable/ic_app_icon"/>
<meta-data
           android:name="com.humanid.sdk.applicationName"
           android:value="@string/app_name"/>
<meta-data  
           android:name="com.humanid.sdk.applicationId"
           android:value="YOUR_APP_ID"/>
<meta-data
           android:name="com.humanid.sdk.applicationSecret"
           android:value="YOUR_APP_SECRET"/>
```

### 4. **Using the SDK in Kotlin**

Add this code to your Activity or Fragment file. We recommend you wrap this in a function that handles the login button.

```bash
LoginManager.getInstance(this).registerCallback(object : LoginCallback {
               override fun onCancel() {  }

             override fun onSuccess(exchangeToken: String) {
                 //todo: send the exchangeToken to your server
               }

             override fun onError(errorMessage: String) {  }
             })
             ...
             ..
             .
             override
             fun onActivityResult(requestCode: Int, resultCode:Int, data: Intent?) {
               LoginManager.getInstance(this).onActivityResult(requestCode, resultCode, 
data)
               super.onActivityResult(requestCode, resultCode, data)
             }
```

### 5. **Using the SDK in Java**

Add this code to your Activity or Fragment file. We recommend you wrap this in a function that handles the login button.

```bash
LoginManager.INSTANCE.getInstance(this).registerCallback(new LoginCallback() {
               @Override
               public void onCancel() {}

             @Override
               public void onSuccess(@NotNull String exchangeToken) {
                 //todo: send the exchangeToken to your server
               }

             @Override
               public void onError(@NotNull String errorMessage) {}

           });
           ...
           ..
           .
           @Override
           protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent 
data) {
                LoginManager.INSTANCE.getInstance(this).onActivityResult(requestCode, 
resultCode, data);
                super.onActivityResult(requestCode, resultCode, data);
            }
```

### 6. You Are All Set!

Your Android app should now be integrated with the humanID login.

## Sample

See our Github for a full [sample](https://github.com/human-internet/humanid-android-sdk) to learn more!

* **Warning!** To run the example project, clone the repo, and run pod install from the Example directory first.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.human-id.org/android-sdk-integration-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
