AssetFile service. The AssetFile API enables your app to manage downloadable content (DLC) — additional files such as expansion packs, level data, or media assets that users can download after installing your app, rather than bundling everything in the initial APK. The sample focuses on service setup and initialization verification — it does not demonstrate downloading, listing, or managing asset files. View the sample source code on GitHub.HorizonServiceConnectionAssetFile service class in a ViewModelAssetFile service initialized without errorsassetfile/ project in Android Studio. Before running the sample, replace the APPLICATION_ID property in MainActivity.kt with your application ID from the Meta Quest Developer Center. Connect your Quest device, build the project, and deploy to your device. The repository README contains build troubleshooting and advanced configuration options.| File | What it demonstrates | Key concepts |
|---|---|---|
MainActivity.kt | SDK service connection and Compose UI setup | HorizonServiceConnection.connect(), Material3 Compose UI, accessibility semantics |
AssetFileViewModel.kt | AssetFile service instantiation and initialization verification | ViewModel-scoped SDK object, coroutine-based error handling, reactive state management |
app/build.gradle.kts | SDK dependency configuration | Horizon Platform SDK artifact ( asset-file-kotlin:0.2.0), Kotlin version, compile/target SDK |
libs.versions.toml | Version catalog for dependencies | Centralized version management, PSDK version pinning |
AssetFile service and a Check Initialization button. Tap the button to verify that the AssetFile service initialized successfully. The sample displays a success message in a card if initialization succeeds, or an error message if it fails.HorizonServiceConnection.connect(
APPLICATION_ID,
this@MainActivity.applicationContext,
lifecycleScope,
)
MainActivity.kt for the complete implementation.AssetFile instance is created as a class-level property in the ViewModel, ensuring it survives configuration changes:private val assetFile = AssetFile()
Dispatchers.IO to avoid blocking the main thread:viewModelScope.launch(Dispatchers.IO) {
// SDK work here
}
checkInitialization() method in AssetFileViewModel.kt.StateFlow to expose UI state changes from the ViewModel. The UI observes state via collectAsStateWithLifecycle() and recomposes automatically when state updates:val uiState by viewModel.uiState.collectAsStateWithLifecycle()
AssetFile API methods to query downloadable content available for your application.