# Native Android SDK

Use the native SmartLinks SDK in Kotlin/Java Android apps without Flutter. The full package combines analytics and native UI modules. The example dependency below is the published 2.0.2 release.

## Add the dependency

Make sure `mavenCentral()` is in your project's dependency repositories, then add this to the app module's `build.gradle.kts`:

```kotlin
dependencies {
    implementation("live.smartlinks:smartlinks-sdk:2.0.2")
}
```

The native UI module requires Android API 24 or newer and targets Java/JVM 11. Use a compatible Android Gradle toolchain. For integrations without native UI, the separate `smartlinks-sdk-core` artifact provides the core bridge; its API is not interchangeable with every full-package UI example.

## Initialize in your Application

```kotlin
import android.app.Application
import com.alkashier.smartlinks.SmartLinks

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        SmartLinks.initialize(
            context = this,
            apiKey = "YOUR_API_KEY",
            debugMode = BuildConfig.DEBUG,
        )
    }
}
```

Register `.MyApplication` with `android:name` on your manifest's `<application>` element. If you already have an Application class, add initialization there instead of replacing it. `BuildConfig` should be your host app's generated class.

## Send an event

Call this after initialization, from a context where `applicationContext` is available:

```kotlin
SmartLinks.analytics.sendEvent(
    eventName = "integration_test",
    params = mapOf("screen" to "home"),
    context = applicationContext,
)
```

Use non-sensitive properties. Never send API credentials, passwords or raw purchase receipts as event metadata.

## Configure deep links

Inside the activity that receives your links:

```xml
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https"
          android:host="smartlinks.live"
          android:pathPrefix="/l/YOUR_APP_SLUG/" />
</intent-filter>
```

Replace the slug and domain with your app's configuration. This covers long-form app links, not every short-link path. Configure the actual paths you use and register the correct package name and signing fingerprints in SmartLinks.

Forward the launch intent and subsequent link intents from your Activity using `SmartLinks.handleDeepLink(this, intent)`. Handle subsequent intents in `onNewIntent`, after calling the superclass implementation. Validate a received route before navigating.

## Optional native screens

After initialization, call `SmartLinks.openFeedback(activity)` or `SmartLinks.openApps(activity)` from an active Activity. Community, blogs and ads also have native modules; configure their required services before enabling them.

## Confirm delivery

Run the app, send `integration_test`, then check the matching app's private analytics view. Verify installed-app links on a physical device and repeat with the release signing certificate before distribution.

For errors and key handling, see [API keys and security](/docs/authentication). Published artifact versions are listed in [Maven Central metadata](https://repo.maven.apache.org/maven2/live/smartlinks/smartlinks-sdk/maven-metadata.xml).
