ShareID
  • SDKs
    • Web
    • iOS
    • Android
    • Flutter
    • React Native
  • Photo-based authenticity API
  • Get a Token
    • Get a Token - Onboarding
    • Get a Token - Authenticate
  • Get the Analysis Result
    • Get Result - Onboarding
    • Get Result - Authenticate
  • AI Analysis Result
    • Analysis Result - Onboarding
    • Analysis Result - Authenticate
  • Message Handler
  • Changelog
    • SDK Web
    • SDK iOS
    • SDK Android
    • Photo-based authenticity API
  • Terminology
  • Api
  • FAQ
Powered by GitBook
On this page
  • Getting started
  • 1. Set up the SDK
  • 2. Get a token
  • 3. Start an onboarding or authenticate flow
  • 4. Get the user workflow result from SDK
  • 5. Get the analysis result
  • Customisation
  • Configuration
  • Localisation
  • FAQ
Edit on GitHub
  1. SDKs

Android

This is a walkthrough of how you can integrate the Onboarding or Authenticate SDK for Android/Kotlin applications.

PreviousiOSNextFlutter

Last updated 4 days ago

Latest version:

Only for versions higher than 1.0.8

Versions after 1.0.8 bring significant enhancements to improve performance and ensure consistency between development environments. Although we have kept client-side changes to a minimum, we recommend that you consult the updated integration guide to make full use of the SDK's capabilities.

To support backward compatibility and ease migration, the “Old version” section offers references to help adapt your current integration.

Getting started

In order to perform an Onboarding or an Authenticate, you should follow those steps:

  1. : install and import the SDK

  2. : request a token using your business credentials

  3. : launch a user workflow

  4. : use the Message handler to get insights about the user workflow

  5. : use your callback or the endpoint to get the analysis result

1. Set up the SDK

1.1. Project requirements

The proper functioning of the SDK necessitates the provision of several parameters. These parameters are essential for enabling the full range of functionalities offered by the SDK.

  • minSdk or minSdkVersion = 24

1.2. Install SDK

ShareID use Maven to provide its SDK securely with authentication managed directly in dependencyResolutionManagement into your settings.gradle file.

repositories {
    google()
    mavenCentral()
    maven {
        url = uri("https://repository.shareid.net/repository/mvn-hosted/")
        credentials {
            username = "<your-repository-username>"
            password = "<your-repository-password>"
        }
    }
}

1.3. Add the dependency

To install the SDK, you'll need to add the dependency in your app module.

  1. Add the following to your build.gradle

implementation("ai.shareid:sdk:+") // or specific version
  1. You can now synchronise and use the SDK in your project

Make sure you update your various dependencies, distributionUrl, IDE, gradle version or anything else.

Conflicts of dependency

The SDK directly integrates most of the dependencies it uses to simplify your integration.

2. Get a token

Use the credentials you received from ShareID's team to get an authentication token and launch an onboarding or authenticate workflow.

3. Start an onboarding or authenticate flow

Once you have added the SDK as a dependency and have your credentials, you can configure the SDK.

Kotlin

ShareID.shared.start(service: "<service>", token: "<your-token>")

Java

ShareID.Companion.getShared().start(service: "<service>", token: "<your-token>")

Kotlin

private val activityResultLauncher = registerForActivityResult(
    ActivityResultContracts.StartActivityForResult()
) { result ->
    if (result.resultCode == Activity.RESULT_OK) {
        val data: Intent? = result.data
    }
}

private fun launchShareIdActivity() {
    val intent = Intent(this, ShareIdMainActivity::class.java).apply {
        putExtra(ShareIdMainActivity.SHARE_ID_METHOD, ShareIdMainActivity.SHARE_ID_ONBOARDING) // or SHARE_ID_AUTHENTICATE for Authenticat
        putExtra(ShareIdMainActivity.SHARE_ID_SERVICE_TOKEN, "<your-token>")
        
        // only for Authenticate
        putExtra(ShareIdMainActivity.SHARE_ID_APPLICANT_ID, "<your-applicant-id>")
        
        // To change the language
        putExtra(ShareIdMainActivity.SHARE_ID_LANGUAGE, "en") // See supported languages at the end of the documentation
    }

    activityResultLauncher.launch(intent)
}

Java

private ActivityResultLauncher<Intent> activityResultLauncher = 
    registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
        onActivityResult(1, result);
    });

private void launchShareIdActivity() {
    Intent intent = new Intent(getBaseContext(), ShareIdMainActivity.class);

    intent.putExtra(ShareIdMainActivity.SHARE_ID_METHOD, ShareIdMainActivity.SHARE_ID_ONBOARDING); // or SHARE_ID_AUTHENTICATE for Authenticate
    intent.putExtra(ShareIdMainActivity.SHARE_ID_SERVICE_TOKEN, "<your-token>");
    
    // only for Authenticate
    intent.putExtra(ShareIdMainActivity.SHARE_ID_APPLICANT_ID, "<your-applicant-id>");
    
    // To change the language
    intent.putExtra(ShareIdMainActivity.SHARE_ID_LANGUAGE, "en"); // See supported languages at the end of the documentation
    
    activityResultLauncher.launch(intent);
}

These examples also work with versions higher than 2.0.0, but we strongly recommend that you use the most recent method.

The service specifies the service in the SDK:

  • onboarding starts the onboarding process

  • authenticate starts the authenticate process

The initial SDK screen is automatically triggered upon execution of the method above.

But there is a third parameter for defining a context in the event that it cannot be retrieved.

4. Get the user workflow result from SDK

To receive feedback from the SDK, you need to implement the messageHandler closure, which manages various responses from the ShareID process.

This closure is triggered when the ShareID SDK completes an operation, fails, or encounters an error.

Kotlin

ShareID.shared.messageHandler = { result ->
    when (result.type) {
        success -> {
            // ...
        }
        exit -> {
            // ...
        }
        failure -> {
            // ...
        }
    }
}

Java

ShareID.Companion.getShared().setMessageHandler(result -> {
    switch (result.getType()) {
        case success:
            // ...
        case exit:
            // ...
        case failure:
            // ...
    }
    return null;
}); 
private void onActivityResult(int requestCode, ActivityResult result) {
    if (requestCode == 1) {
        ShareId.getInstance().messageHandler(result, new MessageHandler() {
            @Override
            public void success(ShareIdResult shareIdResult) {
                // ...
            }

            @Override
            public void exit(ShareIdResult shareIdResult) {
                // ...
            }

            @Override
            public void failure(ShareIdResult shareIdResult) {
                // ...
            }
        });
    }
}

This example only works with versions lower than 2.0.0.

5. Get the analysis result

When the processing of an onboarding or authenticate request is finished, you may receive the result through the callback if you provided it. You may also, fetch yourself the result by calling our API.

Customisation

The ShareID Android SDK is built to be highly customisable, allowing for flexibility through various configuration options or by applying themes to adapt the user interface to your needs.

Configuration

To customise the SDK, pass a ShareID.Theme after building the flow.

Kotlin

ShareID.shared.theme = ShareID.Theme()

Java

ShareID.Companion.getShared().setTheme(new Theme());

Set the colors

Kotlin

theme.colors.primary = ...
theme.colors.secondary = ...

Java

theme.getColors().setPrimaryColor(<your-color-argb>);
theme.getColors().setSecondaryColor(<your-color-argb>);

Name

Message

Color

primary

The main color

ShareID blue (if nothing defined)

secondary

The main title text color

Black or White (depending on your light/dark theme and if nothing is set)

The SDK uses the device language, but you can use the language parameter to force a language before initialising the SDK.

Kotlin

ShareID.shared.language = .en

Java

ShareID.Companion.getShared().setLanguage(ShareID.Language.en);

As soon as an error is returned by the SDK, an error screen is automatically displayed. Change the shouldShowError parameter if you want to stop displaying them.

Kotlin

ShareID.shared.shouldShowError = false

Java

ShareID.Companion.getShared().setShouldShowError(false);

Disabling this parameter exposes the SDK to potential malfunctions. Make sure you handle errors in your application by following what the response handler returns.

The SDK doesn't display logs in the console by default, but you can decide to display them by setting the verbose variable to true.

Kotlin

ShareID.shared.verbose = true

Java

ShareID.Companion.getShared().setVerbose(true);

Localisation

Languages supported:

  • 🇸🇦 (ar), 🇩🇪 (de), 🇬🇧 (en), 🇪🇸 (es), 🇫🇷 (fr), 🇮🇹 (it), 🇵🇱 (pl), 🇵🇹 (pt), 🇷🇴 (ro), 🇷🇺 (ru)

FAQ

Why does the SDK crash during scanning?

If you use minifyEnabled in your code, Android attempts to remove unused classes. Without adding the appropriate rule in your ProGuard file, some ShareID classes may also be minified, potentially leading to unpredictable behavior, random errors, or crashes.

To prevent this issue, add the following rule to your proguard-rules.pro file:

-keep class com.shareid.sdk.** { *; }


Technical support and contact 💬

However, conflicts may arise that require you to integrate dependencies yourself (notably , , , etc.).

Depending on the SDK you are integrating (Onboarding/Authenticate), you may use an API here

To view all possible end-of-process results in our SDK, please refer to the for all success, exit and failure states.

See for more details.

kotlin
material3
compose
Get a Token
Message Handler
Get the analysis result
support@shareid.ai
2.4.8
Set up the SDK
Get a token
Start an onboarding or authenticate flow
Get the user workflow result from SDK
Get the Analysis result