> For the complete documentation index, see [llms.txt](https://docs.idlayr.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idlayr.com/products/number-verification/secure-sna/integration/android.md).

# Android

{% hint style="info" %}
**Device API** · NV 1.0 · GA
{% endhint %}

The Android SDK is `idlayr-sdk-android`. Kotlin, `minSdk 24`, `targetSdk 36`, Java 11. Distributed via private Cloudsmith Maven.

This page covers the device-side integration. For the backend role, see [Backend integration](/products/number-verification/secure-sna/integration/backend.md).

## 1. Install the SDK

Add `com.idlayr:idlayr-sdk-android` to your Gradle dependencies. The artefact is fetched from a private Cloudsmith Maven repository — you'll need a Cloudsmith entitlement token (shared during onboarding).

See the Android SDK installation page for the full Gradle configuration.

## 2. SDK initialisation

The Android SDK auto-initialises via Android's `ContentProvider` mechanism. **There is no public `initializeSdk(...)` method** — calling one is unnecessary and would not compile.

Access the SDK instance through the singleton:

```kotlin
val sdk = IDlayrSDK.getInstance()
```

## 3. Obtain the verification URL

Your backend mints the OAuth2 access token and creates the check on IDlayr. **It hands only the `url` to your Android app**, over your own application API — the OAuth2 access token never leaves the backend. See [Backend integration](/products/number-verification/secure-sna/integration/backend.md).

## 4. Drive the verification

Pass the verification URL to the SDK's Secure SNA method. The SDK forces the request over the cellular network, follows the redirect chain (plain HTTP, no `Authorization` header required), and returns a `JSONObject` with the result.

```kotlin
val sdk = IDlayrSDK.getInstance()

val resp = sdk.openWithDataCellular(
    URL(verificationURL),
    false  // debug flag
)
```

## 5. Response handling

```kotlin
val errorCode = resp.optString("error")
if (errorCode.isNotEmpty()) {
    // SDK-level error — see SDK errors below
    val errorDescription = resp.optString("error_description", "")
    return
}

when (resp.optInt("http_status")) {
    200 -> {
        val body = resp.optJSONObject("response_body")
        val code = body?.optString("code")
        val checkId = body?.optString("check_id")
        // Send code + checkId to your backend for completion
    }
    400 -> { /* MNO not supported */ }
    412 -> { /* Not a mobile IP */ }
    else -> { /* Other error */ }
}
```

## 6. Send the code to your backend

Your backend completes the check by redeeming the code with POST. See [Backend integration](/products/number-verification/secure-sna/integration/backend.md#4-complete-the-check).

## Optional: 2G network detection

The SDK can detect if the device is on an insecure 2G network (GPRS, EDGE, CDMA, 1xRTT, IDEN). 2G doesn't support Secure SNA reliably; you may want to skip the call.

```kotlin
if (sdk.isRunningOn2G()) {
    // Device is on 2G — fall back to another verification method
}
```

This check requires the `READ_PHONE_STATE` permission in your manifest. If the permission is missing or not granted at runtime, `isRunningOn2G()` returns `false` (degrades gracefully).

## SDK errors

Same set as iOS:

* `sdk_no_data_connectivity` — device has no cellular data path.
* `sdk_connection_error` — network-level failure during the request.
* `sdk_redirect_error` — error while following the redirect chain.
* `sdk_error` — generic SDK failure.
* `invalid_scheme` — URL was not HTTPS.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.idlayr.com/products/number-verification/secure-sna/integration/android.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
