> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dataspike.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Android SDK

> On-device deepfake detection SDK for Android — real-time, offline, and efficient analysis of video and audio streams.

📦 **GitHub:** [Dataspike Deepfake SDK for Android](https://github.com/dataspike-io/Deepfake-MobileSDK-Android)

***

The **Dataspike Deepfake SDK for Android** provides a compact, high-performance framework for detecting AI-generated or manipulated video and audio directly **on-device** — **no internet connection required**.

Built on Dataspike’s deepfake detection engine, the SDK delivers **real-time analysis**, **low latency**, and **enterprise-grade accuracy**, even on mid-tier Android devices. It supports both **video** and **streaming audio** detection and integrates seamlessly with **Jetpack Compose**, **WebRTC**, and **standard Android views**.

> ⚡ **Key advantage:** All inference runs **locally on the device** using a lightweight yet powerful model — ensuring privacy, speed, and reliability in fully offline scenarios.

[Github](https://github.com/dataspike-io/Deepfake-MobileSDK-Android)

***

## Highlights

* 🚀 **On‑device inference** — no internet dependency, no data upload.
* 🧠 **Optimized neural model** — compact yet accurate, built for real‑time response.
* 🎥 **Video & streaming support** — compatible with `SurfaceView`, `TextureView`, and `WebRTC VideoTrack`.
* 🔒 **Privacy-first architecture** — no cloud processing; user content never leaves the device.
* ⚙️ **Kotlin‑first API** — clean, composable, and easy to integrate.
* ⚡ **Ultra‑efficient runtime** — smooth detection at 30+ FPS on mid-tier hardware.

> You can also [download the demo app](https://github.com/dataspike-io/Deepfake-MobileSDK-Android/releases/download/v1.0.0/deepfake-demo-app-1.0.0.apk) showcasing real-time detection on device.

***

## Integration Guide

### 1. Add the Maven Repository

Add the Dataspike SDK Maven repository in your `settings.gradle.kts`:

```kotlin theme={null}
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://raw.githubusercontent.com/dataspike-io/Deepfake-MobileSDK-Android/release") }
    }
}
```

### 2. Add the SDK Dependency

In your app’s `build.gradle.kts`, include:

```kotlin theme={null}
dependencies {
    implementation("io.dataspike:deepfake-sdk:VERSION")
}
```

Replace `VERSION` with the latest SDK release number.

***

## Initialization

Before analysis, initialize the SDK with your valid **license key**.

```kotlin theme={null}
val deepfakeSDK = DeepfakeSDK.getInstance()

val success = deepfakeSDK.initialize(
    applicationContext = applicationContext,
    license = "YOUR_LICENSE_KEY",
    nativeLogLevel = 4,        // Optional: Log level (0–5)
    deepfakeThreshold = 0.5f,  // Optional: Adjust detection sensitivity
)
```

If initialization succeeds, the SDK is ready to analyze both video and audio in real time.

***

## Video or WebRTC Analysis

You can analyze frames directly from a standard Android `View` or a WebRTC `VideoTrack`.\
Provide an `AnalysisCallback` to receive frame-by-frame results.

```kotlin theme={null}
val analysisCallback = object : AnalysisCallback {
    override fun onFrameAnalysisResult(result: AnalysisResult, message: String?) {
        // Handle frame result here (e.g., show confidence score)
    }

    override fun onAudioAnalysisResult(result: String) {
        // Handle audio analysis result (if applicable)
    }

    override fun onAnalysisError(error: String) {
        // Handle any errors
    }
}

// Analyze a view
deepfakeSDK.startAnalysis(yourView, analysisCallback)

// Or analyze a WebRTC track
deepfakeSDK.startAnalysis(yourVideoTrack, analysisCallback)
```

> **Tip:** For real-time streams, prefer WebRTC integration. For local files, attach a `SurfaceView` or `TextureView` with playback controls.

***

## Audio-Only Analysis

To detect manipulation in live or recorded speech, you can start an **audio-only session**:

```kotlin theme={null}
deepfakeSDK.startAudioAnalysis(analysisCallback)
```

Feed raw PCM audio data (16 kHz, `ShortArray`) to the SDK in small chunks:

```kotlin theme={null}
deepfakeSDK.processAudioChunk(yourAudioData)
```

> The SDK processes \~3 s (48,000 samples) per chunk. Shorter segments should be zero‑padded.

***

## Stop and Clean Up

When analysis is complete or the user session ends:

```kotlin theme={null}
deepfakeSDK.stopAnalysis()
deepfakeSDK.shutdownWithTimeout()
```

This releases all SDK resources and gracefully closes background threads.

***

## Performance Notes

* Runs entirely **on-device** — ideal for **offline** or **privacy‑sensitive** apps.
* The deepfake model is **quantized** and **optimized for mobile GPUs**, achieving real-time performance even on **mid-tier Snapdragon and Dimensity** devices.
* Supports continuous analysis of **video + audio streams** with minimal impact on battery or CPU.
* All computations are **ephemeral** — no frame storage or network transfer.

> Typical latency: **10 ms per frame** (mid-tier device, 720p stream).

***

## Licensing

You must provide a valid **license key** during initialization.\
Licenses can be requested through your Dataspike dashboard or account manager.

If the SDK is not initialized or an invalid key is used, detection methods will fail gracefully with an error callback.

***

## Demo Application

A fully functional **demo APK** is available for download:\
👉 [deepfake-demo-app‑1.0.0.apk](https://github.com/dataspike-io/Deepfake-MobileSDK-Android/releases/download/v1.0.0/deepfake-demo-app-1.0.0.apk)

This demo demonstrates:

* Real-time video and audio deepfake detection
* Frame-level confidence scores
* Offline inference and responsive UI updates

***

## Summary

The Dataspike Deepfake SDK enables developers to embed **AI-manipulation detection** directly inside Android apps — without sending data to the cloud.\
It’s optimized for **speed**, **accuracy**, and **privacy**, providing true on-device protection against synthetic media threats.

> 🔒 **Offline. Real-time. Private.**\
> Detect deepfakes anywhere — no connection required.
