Develop

Rate and Review sample overview

Updated: May 8, 2026

Overview

:::caution The Rate and Review API is not yet available in the Horizon Platform SDK. This sample is a placeholder that demonstrates SDK connection patterns only. The API will ship in a future SDK release. :::
The Rate and Review sample demonstrates the architecture and connection patterns used across all Horizon Platform SDK samples, including Horizon Service initialization, MVVM state management with Jetpack Compose, and error handling. View the sample source code on GitHub.

What you will learn

  • Connect to the Horizon Service using HorizonServiceConnection.connect()
  • Structure UI state with MVVM using StateFlow and Jetpack Compose
  • Collect and render state changes with collectAsStateWithLifecycle()
  • Handle initialization errors and display them in Material 3 UI components
  • The project structure and build configuration shared by all Horizon Platform SDK samples

Requirements

  • A Meta Quest device running the latest OS version
  • Android Studio with Kotlin support
  • A configured Horizon Platform SDK project
For setup instructions, see the Horizon Platform SDK setup guide.

Get started

Clone or download the Horizon Platform SDK samples repository and open the rateandreview/ project in Android Studio. Configure your APPLICATION_ID in MainActivity.kt following the setup instructions provided in the code comments, then build and deploy the sample to your Quest device. For detailed build instructions, see the sample’s README.

Explore the sample

FileWhat it demonstratesKey concepts
MainActivity.kt
Entry point that connects to Horizon Service, defines the RateAndReviewScreen composable
HorizonServiceConnection.connect(), collectAsStateWithLifecycle(), Material 3 components
RateAndReviewViewModel.kt
ViewModel managing UI state with StateFlow
RateAndReviewUiState data class, MutableStateFlow, coroutine-based state updates
RateAndReviewViewModelTest.kt
Unit tests for UI state data class
Testing state defaults and immutability with copy()
app/build.gradle.kts
Build configuration declaring SDK dependencies
Minimum SDK 34, target SDK 36, PSDK core dependency

Runtime behavior

When you run the sample and press the Check Initialization button, the UI displays: “Rate and Review sample initialized. The Rate and Review API will be available in a future SDK release.” The loading indicator appears briefly, then the result message confirms the API is not yet implemented. No actual Rate and Review API calls occur.

Key concepts

Horizon Service connection

The sample connects to the Horizon Service in MainActivity.onCreate():
HorizonServiceConnection.connect(
    APPLICATION_ID,
    this@MainActivity.applicationContext,
    lifecycleScope,
)

MVVM state management with StateFlow

The ViewModel holds a private MutableStateFlow and updates it atomically using the update extension function:
private val _uiState = MutableStateFlow(RateAndReviewUiState())
val uiState: StateFlow<RateAndReviewUiState> = _uiState

Error handling pattern

The sample wraps ViewModel operations in try-catch blocks within coroutines launched on Dispatchers.IO. Caught exceptions surface through the errorMessage property of RateAndReviewUiState, rendered in a Material 3 error container card.

Extend the sample

When the Rate and Review API becomes available, this sample will be updated. In the meantime, explore these functional sibling samples:
  • Users sample: Shows how to fetch and display user profiles with real API calls.
  • In-App Purchases sample: Demonstrates product catalog retrieval and purchase flow.
  • Achievements sample: Shows how to query and unlock achievements.