> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch36-native-client-apps/36.3-android-node-app.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 36.3 Android Node Application

> **Generated by**: Claude Opus 4.6 (initial draft) / Claude Opus 5 (`v2026.3.9` revision) **Token usage**: Input \~185k tokens, Output \~5k tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

The Android application, like the iOS application, plays the role of a "node"—connecting to a Gateway and exposing the device's hardware capabilities. It is built with **Kotlin + Jetpack Compose** and is the only native client running on a non-Apple platform among the three native clients.

## 36.3.1 Kotlin Architecture

### Project Configuration

The Android application is located in `apps/android/` and uses Gradle for building:

```kotlin
// apps/android/app/build.gradle.kts
android {
    namespace = "ai.openclaw.android"
    compileSdk = 36
    defaultConfig {
        applicationId = "ai.openclaw.android"
        minSdk = 31        // Android 12 (S) minimum
        targetSdk = 36
    }
    buildFeatures {
        compose = true      // Jetpack Compose UI
        buildConfig = true
    }
}
```

It's worth noting that `assets.srcDir` points to the shared library's resource directory—the Android app directly reuses resource files from `OpenClawKit` (such as sound effects and icons), but since Kotlin cannot directly use Swift packages, protocols and models need to be reimplemented in Kotlin.

### Source Code Structure

```
apps/android/app/src/main/java/ai/openclaw/android/
├── MainActivity.kt              # Activity entry point
├── MainViewModel.kt             # ViewModel state management
├── NodeApp.kt                   # Application subclass
├── NodeRuntime.kt               # Core runtime (similar to iOS NodeAppModel)
├── NodeForegroundService.kt     # Foreground service (maintain connection)
├── SecurePrefs.kt               # Encrypted preference storage
├── SessionKey.kt                # Session key
├── gateway/                     # WebSocket connection + service discovery
│   ├── GatewaySession.kt
│   ├── GatewayDiscovery.kt
│   ├── DeviceAuthStore.kt
│   └── DeviceIdentityStore.kt
├── node/                        # Device capability implementations
│   ├── CanvasController.kt
│   ├── CameraCaptureManager.kt
│   ├── ScreenRecordManager.kt
│   ├── LocationCaptureManager.kt
│   └── SmsManager.kt
├── protocol/                    # Gateway protocol types
│   ├── OpenClawCapability.kt
│   ├── OpenClawCameraCommand.kt
│   ├── OpenClawCanvasCommand.kt
│   └── OpenClawScreenCommand.kt
├── chat/                        # Chat functionality
├── voice/                       # Voice wake + Talk Mode
│   ├── VoiceWakeManager.kt
│   └── TalkModeManager.kt
└── ui/                          # Compose UI
```

### NodeRuntime Core

`NodeRuntime` is the core runtime of the Android application, aggregating all device capabilities:

```kotlin
// apps/android/app/src/main/java/ai/openclaw/android/NodeRuntime.kt
class NodeRuntime(context: Context) {
    private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
    
    val prefs = SecurePrefs(appContext)
    val canvas = CanvasController()
    val camera = CameraCaptureManager(appContext)
    val location = LocationCaptureManager(appContext)
    val screenRecorder = ScreenRecordManager(appContext)
    val sms = SmsManager(appContext)
    
    private val voiceWake: VoiceWakeManager by lazy {
        VoiceWakeManager(context = appContext, scope = scope,
            onCommand = { command -> ... })
    }
}
```

Corresponding to iOS's `NodeAppModel`, `NodeRuntime` creates and holds instances of all capability managers. It uses Kotlin coroutines (`CoroutineScope` + `SupervisorJob`) for asynchronous operations.

> **Sidebar — Kotlin Coroutines and SupervisorJob**
>
> Kotlin coroutines are Kotlin's asynchronous programming solution, similar to Swift's async/await. `CoroutineScope` defines the lifecycle scope of coroutines, and `SupervisorJob` ensures that the failure of one child coroutine does not cancel other sibling coroutines—this is important for node runtime because camera failure should not affect location services.

### Foreground Service

Android requires long-running background tasks to be implemented through **Foreground Services**. `NodeForegroundService` is started in `MainActivity.onCreate`:

```kotlin
// MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
    NodeForegroundService.start(this)  // Start foreground service
    // ...
}
```

The foreground service displays a persistent notification in the notification bar, informing the user that OpenClaw is running. This ensures that the WebSocket connection is not killed by the system even if the user switches to other applications.

## 36.3.2 Canvas / Camera / Screen Recording

The device capabilities exposed by the Android node align with iOS:

| Capability       | Manager                  | Android API         |
| ---------------- | ------------------------ | ------------------- |
| Canvas           | `CanvasController`       | WebView (optional)  |
| Camera           | `CameraCaptureManager`   | Camera2 API         |
| Screen Recording | `ScreenRecordManager`    | MediaProjection API |
| Location         | `LocationCaptureManager` | LocationManager     |
| SMS              | `SmsManager`             | SmsManager API      |

Each capability manager needs to integrate with Android's permission system. `PermissionRequester` handles runtime permission requests uniformly:

```kotlin
// MainActivity.kt
permissionRequester = PermissionRequester(this)
viewModel.camera.attachPermissionRequester(permissionRequester)
viewModel.sms.attachPermissionRequester(permissionRequester)
viewModel.screenRecorder.attachScreenCaptureRequester(screenCaptureRequester)
```

Screen recording is special: Android's `MediaProjection` API not only requires runtime permissions but also requires explicit user consent in a system dialog, so it has a separate `ScreenCaptureRequester`.

MainActivity also monitors the `preventSleep` state flow, setting `FLAG_KEEP_SCREEN_ON` when needed to prevent the screen from turning off automatically—this is important during Canvas display or conversation mode.

## 36.3.3 Optional SMS Support

An Android-exclusive capability is **SMS text messaging** support. When users grant SMS permissions, AI agents can read and send SMS messages through `SmsManager`. This is not possible on iOS due to system restrictions.

The declaration and use of SMS capability follows the same pattern as other capabilities: declared via capabilities when connecting to the Gateway, and the Gateway decides whether to expose SMS-related tools based on this.

```
OpenClawCapability:
  - canvas
  - camera
  - screen
  - voiceWake
  - location
  - sms          ← Android-exclusive
```

***

## Summary of This Section

1. **The Android application is built with Kotlin + Jetpack Compose + Gradle**, supporting Android 12 (API 31) as the minimum.
2. **NodeRuntime is the core runtime**, using Kotlin coroutines and SupervisorJob to manage various device capability managers.
3. **Foreground service** ensures the WebSocket connection is not terminated by the system in the background, informing users through persistent notifications.
4. **Device capabilities** (Canvas, camera, screen recording, location, SMS) each have independent managers, unified through PermissionRequester for permission handling.
5. **SMS is an Android-exclusive capability**, allowing AI agents to read and write text messages.
