Android

The Android SDK wraps the Lean Link SDK in an Activity-based WebView, exposed via a fluent Lean.Builder() API and a Lean.Listener callback interface.

šŸ“˜

Prerequisites

Before calling any SDK method you need to have completed the backend setup in the Getting Started section:

This page covers only the client-side SDK integration.

Installation

Add JitPack to your project's build.gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

Add the dependency in your module's build.gradle:

dependencies {
    implementation "me.leantech:link-sdk-android:X.X.X"
}

The latest version is on JitPack.

Setup

Instantiate Lean once via the Builder:

val lean = Lean.Builder()
    .setAppToken("<YOUR_APP_TOKEN>")
    .setVersion("latest")
    .setCountry("ae")     // or "sa"
    .setLanguage("en")    // or "ar"
    .setSandboxMode()     // remove for production
    .showLogs()           // development only
    .build()

Listener pattern

Every method requires a Lean.Listener that receives a Lean.Response on completion, cancellation, or error.

lean.connect(
    activity = this,
    customerId = "CUSTOMER_ID",
    // ... other fields
    leanListener = object : Lean.Listener {
        override fun onResponse(response: Lean.Response) {
            when (response.status) {
                "SUCCESS"   -> { /* flow completed */ }
                "CANCELLED" -> { /* user cancelled */ }
                "ERROR"     -> { /* inspect response.message, response.secondaryStatus */ }
            }
        }
    }
)

See LinkSDK statuses for the full list of status codes.

Available methods

All methods accept camelCase parameters (e.g. customerId, paymentDestinationId). Every call takes an activity reference as its first argument — the LeanActivity launches over it — and a Lean.Listener that receives the Lean.Response on completion.

.connect()

Link a bank account for data access (and optionally payments).

Required: activity, customerId, permissions.

lean.connect(
    activity = this,
    customerId = "CUSTOMER_ID",
    bankIdentifier = null,
    paymentDestinationId = "PAYMENT_DESTINATION_ID",
    permissions = arrayListOf(
        Lean.UserPermissions.IDENTITY,
        Lean.UserPermissions.ACCOUNTS,
        Lean.UserPermissions.TRANSACTIONS,
        Lean.UserPermissions.BALANCE,
        Lean.UserPermissions.PAYMENTS
    ),
    customization = null,
    accessTo = null,
    accessFrom = null,
    failRedirectUrl = null,
    successRedirectUrl = null,
    accountType = null,
    endUserId = null,
    accessToken = null,
    showConsentExplanation = null,
    destinationAlias = null,
    destinationAvatar = null,
    customerMetadata = null,
    leanListener = /* ... */
)

Customisation

Construct a Lean.Customization and pass it on any method. Every field maps to the same key documented in Customisation (camelCase on Android).

val customization = Lean.Customization().apply {
    themeColor = "#0080ff"
    buttonTextColor = "#ffffff"
    linkColor = "#0080ff"
    overlayColor = "rgba(0, 0, 0, 0.8)"
    buttonBorderRadius = "8"
    dialogMode = "contained"

    // Dark-mode overrides
    themeColorDark = "#1a1a1a"
    buttonTextColorDark = "#ffffff"
}

lean.connect(
    activity = this,
    customerId = "CUSTOMER_ID",
    bankIdentifier = null,
    paymentDestinationId = "PAYMENT_DESTINATION_ID",
    permissions = arrayListOf(Lean.UserPermissions.IDENTITY, Lean.UserPermissions.ACCOUNTS),
    customization = customization,
    accessTo = null,
    accessFrom = null,
    failRedirectUrl = null,
    successRedirectUrl = null,
    accountType = null,
    endUserId = null,
    accessToken = null,
    showConsentExplanation = null,
    destinationAlias = null,
    destinationAvatar = null,
    customerMetadata = null,
    leanListener = /* ... */
)

Language

Pass "en" or "ar" to setLanguage(...) on the Builder. Arabic switches the UI to a full right-to-left layout.

Bank-list and account-selection shortcuts

Pass bankIdentifier to skip the bank-selection screen (Lean bank identifier — see Create your own bank list). Pass accountId on pay to skip the payment-source-selection screen.

Related