PreviewSpatialApi


@RequiresOptIn(level = RequiresOptIn.Level.ERROR, message = "This API is in an unstable preview state and requires a developer preview system image work properly. Do not use this API in release builds as it will likely to lead to crashes.")
@Retention(value = AnnotationRetention.BINARY)
annotation PreviewSpatialApi


Marks declarations that are part of the unstable Spatial API Preview.

These APIs are not final and are subject to change or removal in future releases without notice. They are intended for development and testing purposes only and require a specific developer preview system image to function correctly.

Any usage of a declaration annotated with @PreviewSpatialApi must be explicitly opted-in by annotating the calling code with @OptIn(PreviewSpatialApi::class).

Furthermore, to prevent runtime errors, applications must wrap calls to these APIs in a try-catch block to handle cases where the device does not support the required preview API version.

Example of opting-in and performing a runtime check:


    

fun newPreviewApi() { // ... }

(PreviewSpatialApi::class) fun callPreviewApi() { try { newPreviewApi() } catch (e: NoSuchMethodError) { // Handle the case where the preview API is not available. } }

Summary

Public constructors

Public constructors

PreviewSpatialApi

PreviewSpatialApi()