Android SDK

Embed Polst inside an Android app with first-class Compose and XML View support, native rendering, and an offline-friendly vote replay queue. This page is informational — there's no live render here. Clone the sandbox app to try it on a device or emulator.

What you get

  • First-class Jetpack Compose support via the PolstView composable, plus an XML View for legacy view-based screens.
  • Native rendering — no WebView, no JS bridge. The widget draws with the host app's Compose / Material 3 stack.
  • Offline cache — last-fetched polst payloads are persisted so the widget renders even when the device is offline.
  • Vote replay queue — votes cast offline are queued in a local Room database and replayed by a WorkManager job once connectivity returns.
  • Encrypted device-id and token storage via EncryptedSharedPreferences.
  • Theming via PolstThemeProvider with built-in light / dark palettes (or roll your own).

Screenshots

A single Polst rendered with the Jetpack Compose PolstView composable in the sandbox app.
Single Polst rendered via the Compose PolstView.
The same Polst rendered with the legacy XML View surface in the sandbox app.
Same Polst rendered via the XML View surface for legacy screens.
The offline replay queue flushing a queued vote once connectivity returns.
Offline replay queue flushing once connectivity returns.

Try it locally

  1. Clone the embedding repo: git clone git@github.com:ajcpwnz/polst-embedding.git.
  2. Open the android/ directory in Android Studio, or build the debug APK from the CLI: ./gradlew :example:assembleDebug.
  3. Follow android/README.md for sandbox-specific run notes.
  4. For SDK source, issues, and releases, see the upstream polst-android repo.

Minimal Compose integration

The canonical "render a polst" call. Install the client once at app startup, then drop a PolstView anywhere in your Compose tree.

Copy this snippet

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.polst.sdk.PolstClient
import com.polst.sdk.core.theme.PolstTheme
import com.polst.sdk.core.theme.PolstThemeProvider
import com.polst.sdk.core.theme.light
import com.polst.sdk.ui.PolstView

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

    // One-time at app startup (typically Application.onCreate).
    PolstClient.installDefault(PolstClient.forContext(this))

    setContent {
      PolstThemeProvider(theme = PolstTheme.light) {
        Surface(modifier = Modifier.padding(24.dp)) {
          PolstView(shortId = "abc123XYZ_")
        }
      }
    }
  }
}

Replace "abc123XYZ_" with any real 10-char Polst short id. The snippet is shape-only; copy-paste it into a Kotlin Activity to render a single polst end-to-end.