WindowSdkExtensions


public abstract class WindowSdkExtensions


This class provides information about the extension SDK versions for window features present on this device. Use extensionVersion to get the version of the extension. The extension version advances as the platform evolves and new APIs are added, so is suitable to use for determining API availability at runtime.

Window Manager Jetpack APIs that require window SDK extensions support are denoted with RequiresWindowSdkExtension. The caller must check whether the device's extension version is greater than or equal to the minimum level reported in RequiresWindowSdkExtension.

import androidx.window.WindowSdkExtensions
import androidx.window.embedding.SplitAttributes
import androidx.window.embedding.SplitController
import androidx.window.samples.embedding.context

// For example, SplitController#setSplitAttributesCalculator requires extension version 2.
// Callers must check the current extension version before invoking the API, or exception will
// be thrown.
if (WindowSdkExtensions.getInstance().extensionVersion >= 2) {
    SplitController.getInstance(context).setSplitAttributesCalculator(splitAttributesCalculator)
}

Summary

Public methods

@IntRange(from = 0) int

Reports the device's extension version

static final @NonNull WindowSdkExtensions

Returns a WindowSdkExtensions instance.

Public methods

getExtensionVersion

Added in 1.2.0
public @IntRange(from = 0) int getExtensionVersion()

Reports the device's extension version

When Window SDK Extensions is not present on the device, the extension version will be 0.

getInstance

Added in 1.2.0
public static final @NonNull WindowSdkExtensions getInstance()

Returns a WindowSdkExtensions instance.