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

# Getting started

> Install the Pillow SDK and present your first study on Android

Get the Pillow SDK running in your Android app in a few minutes.

## Prerequisites

* Android API 24+ (Android 7.0)
* A **publishable API key**, which you can create from [Apps and API keys](/sdk/apps-and-keys)
* A **study** set to live mode, with its ID copied from the **Integration** tab

## Installation

Add the Pillow SDK to your app-level `build.gradle.kts`:

```kotlin theme={"theme":{"light":"github-light","dark":"github-dark"}}
dependencies {
    implementation("so.pillow:pillow-android-sdk:0.1.6")
}
```

Make sure `mavenCentral()` is in your repositories block.

## Initialize the SDK

Call `initialize()` once at app startup, typically in your `Application` class or main `Activity`:

```kotlin theme={"theme":{"light":"github-light","dark":"github-dark"}}
import so.pillow.sdk.PillowSDK

PillowSDK.initialize(
    context = applicationContext,
    publishableKey = "pk_live_..."
)
```

<Warning>
  Initialize the SDK only once. Calling `initialize()` multiple times is a no-op.
</Warning>

## Present your first study

Show a study to the user by calling `presentStudy()` from any Activity:

```kotlin theme={"theme":{"light":"github-light","dark":"github-dark"}}
import so.pillow.sdk.PillowStudy

PillowSDK.presentStudy(
    activity = this,
    study = PillowStudy(id = "your-study-id-here")
)
```

The study opens as a modal overlay. The user can complete the interview and dismiss it when done.

## Handle microphone permissions

If your study uses voice input, forward the permission result to the SDK:

```kotlin theme={"theme":{"light":"github-light","dark":"github-dark"}}
override fun onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String>,
    grantResults: IntArray
) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    PillowSDK.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
```

<Info>
  If you skip this step, the microphone button won't appear in studies that support voice input.
</Info>

## Full example

```kotlin theme={"theme":{"light":"github-light","dark":"github-dark"}}
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import so.pillow.sdk.PillowSDK
import so.pillow.sdk.PillowStudy

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        PillowSDK.initialize(
            context = applicationContext,
            publishableKey = "pk_live_..."
        )

        PillowSDK.setExternalId("user_123")
        PillowSDK.setUserProperty("plan", "pro")

PillowSDK.presentStudy(
            activity = this,
            study = PillowStudy(id = "your-study-id-here")
        )
    }

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        PillowSDK.onRequestPermissionsResult(requestCode, permissions, grantResults)
    }
}
```

If you want lifecycle callbacks, pass an anonymous `PillowStudyListener` object to `presentStudy()`. That is the normal Android integration pattern.

## What's next

<CardGroup cols={3}>
  <Card title="Identify users" icon="user" href="/sdk/android/identification">
    Set external IDs and user properties.
  </Card>

  <Card title="Present studies" icon="presentation" href="/sdk/android/studies">
    Control when and how studies appear.
  </Card>

  <Card title="Session management" icon="refresh-cw" href="/sdk/android/session-management">
    Handle logout and session lifecycle.
  </Card>
</CardGroup>
