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

# Android

> Integrate Crycket into your Android app with Kotlin

## Installation

Add the Crycket SDK to your `build.gradle.kts`:

```kotlin theme={null}
dependencies {
  implementation("com.crycketpay:sdk-android:1.0.0")
}
```

## Setup

Initialize the SDK at app startup:

```kotlin theme={null}
import com.crycketpay.sdk.PaymentSDK

val sdk = PaymentSDK.init(
  apiKey = "pk_live_...",
  debug = BuildConfig.DEBUG
)
```

## Wallet interface

Implement the `PaymentWallet` interface for your wallet provider:

```kotlin theme={null}
class MyWallet : PaymentWallet {
  override val address: String = walletAddress
  override val chain: CAIP2ChainId = CAIP2ChainId.SOLANA

  override suspend fun signTransaction(tx: UnsignedTransaction): SignedTransaction {
    // Sign with your wallet provider
  }
}
```

## Requesting a payment

```kotlin theme={null}
// 1. Create an intent
val intent = sdk.createIntent(
  chain = "solana:5eykt4UsFv8P8NJdTREpY1vzqKq2Kvdp",
  token = "USDC",
  amount = "10.50",
  requestor = wallet.address,
  idempotencyKey = "order_982734"
)

// 2. Start audio broadcast
val broadcast = sdk.broadcast(intent)

// 3. Watch for fulfillment
sdk.onStatusChange(intent) { status, context ->
  if (status == IntentState.CONFIRMED) {
    broadcast.stop()
    // Payment complete
  }
}
```

## Fulfilling a payment

```kotlin theme={null}
// 1. Listen for audio signal
val received = sdk.listen()

// 2. Handle with default UI
sdk.onIntentReceived(received.intentId, wallet)

// Or headless mode for custom UI
sdk.onIntentReceived(received.intentId, wallet,
  headless = true,
  onDetails = { intent, summary ->
    // Render payment details
  },
  onComplete = { intent ->
    // Payment confirmed
  },
  onError = { error ->
    // Handle error
  }
)
```
