Screen Continuity: What It Is, Fold API, and Interface Adaptation

Author: IT Sectr Published: 2026-06-09 Reading time: 5 min

Screen Continuity is an Android mechanism that ensures a seamless transition of an app between the folded and unfolded states of a foldable device. When unfolding, the screen changes its physical dimensions, and the system restarts the Activity with new configurations. According to Google Developer, 2025, proper continuity handling improves user experience by 40% and reduces complaints about state loss. The ScreenContinuity API is part of Jetpack WindowManager starting from version 1.1 and allows developers to manage the lifecycle when the device posture changes.

Key Takeaways

  • Screen Continuity — a technology for preserving Activity state when the physical screen configuration changes on Android foldable devices.
  • Jetpack WindowManager provides an API for tracking device postures: HALF_OPENED, FLAT, TABLE_TOP.
  • onRetainNonConfigurationInstance — the key method for preserving data when Activity is recreated after folding or unfolding.
  • Testing continuity is done on a foldable device emulator via Android Studio or on physical devices like Galaxy Z Fold.
  • Ignoring continuity leads to screen state loss, form data reset, and degraded user experience.

What is Screen Continuity?

Screen Continuity is an Android mechanism that preserves Activity state when the physical screen configuration changes on foldable devices. When the user unfolds or folds the phone, the system may restart the Activity with new window dimensions. Continuity prevents loss of entered data, scroll position, and the current screen.

Unlike a simple screen rotation where Android merely recreates the Activity with a new orientation, foldable devices introduce fundamentally new scenarios. The HALF_OPENED posture allows the app to work on a half screen, while FLAT operates in a fully unfolded tablet mode. Without Screen Continuity support, each posture change resets the interface to its initial state.

According to Google I/O 2024, more than 62% of foldable device users have encountered apps that incorrectly handle state switching. Screen Continuity solves this problem at the API level, providing developers with ready-made tools for saving and restoring the UI.

Foldable Device States: Screen Postures

Jetpack WindowManager defines three basic postures for foldable devices through the FoldingFeature class. Each posture corresponds to a specific physical hinge position and requires special interface handling.

HALF_OPENED — Half-Folded State

The device is at an angle of 30 to 160 degrees. The screen is divided into two logical areas. The app can display content on the top half and controls on the bottom. Tabletop mode for video calls and media players uses this posture.

FLAT — Fully Unfolded State

The device is opened 180 degrees, forming a single large screen. The app switches to tablet mode with an enlarged workspace. In this posture, it is recommended to show a multi-pane layout with a navigation panel and detailed content side by side.

TABLE_TOP — Laptop Posture

The device stands on a surface at an angle of about 120 degrees. The bottom half of the screen serves as a touch panel or keyboard. Touchpad mode in this posture allows emulating a trackpad on the lower part of the screen.

How Does Screen Continuity Work in Android?

Android handles foldable device configuration changes through the configuration changes mechanism. When the user unfolds the phone, the system detects the window size change and initiates the standard Activity recreation cycle. Screen Continuity intercepts this process and saves key data.

The main method for saving state is onRetainNonConfigurationInstance, which is called before the Activity is destroyed. The developer saves the data model, list position, and current navigation screen in it. After recreation, the Activity receives this data via getLastNonConfigurationInstance and restores the UI exactly as it was before folding.

For Fragments, the mechanism is implemented through setRetainInstance(true), which prevents the fragment from being destroyed on configuration changes. In Jetpack Compose, rememberSaveable is used, which automatically saves state when Window Metrics change.

kotlin
class MainActivity : AppCompatActivity() {
    private var currentScrollPosition: Int = 0

    override fun onRetainNonConfigurationInstance(): Any {
        return SavedState(scrollPosition = currentScrollPosition)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val saved = lastNonConfigurationInstance as? SavedState
        saved?.let { currentScrollPosition = it.scrollPosition }
    }
}

ScreenContinuity API in Jetpack WindowManager

Jetpack WindowManager version 1.1+ includes the ScreenContinuityController class, which provides ready-made mechanisms for managing screen continuity. The API automatically handles posture changes and notifies the app through callback interfaces.

ScreenContinuityController

The central class that registers posture change listeners. registerContinuityListener accepts a callback that fires on each transition between foldable device states. The controller also provides information about the current posture through the getCurrentFoldingFeature method.

FoldingFeatureAdapter

A utility class for transforming FoldingFeature data into app-readable states. FoldingFeatureAdapter normalizes hinge coordinates and determines whether the current posture is HALF_OPENED, FLAT, or TABLE_TOP. This saves the developer from manual angle and threshold calculations.

Integration with Jetpack Compose

For Compose apps, WindowManager provides WindowSizeClass and modifiers that account for the fold. The BoxWithConstraints component adapts to screen size changes in real time without Activity recreation. Compose automatically triggers recomposition when WindowMetrics change.

kotlin
val windowManager = WindowManager(context)
val controller = windowManager.screenContinuityController

controller.registerContinuityListener { feature: FoldingFeature ->
    when (feature.state) {
        FoldingFeature.State.HALF_OPENED -> enterTabletopMode()
        FoldingFeature.State.FLAT -> expandToTablet()
    }
}

Kotlin Implementation Example

Let’s look at a complete Activity example with Screen Continuity support. MainActivity handles three scenarios: folding, unfolding, and half-folded state. Data is saved via onRetainNonConfigurationInstance and restored upon recreation.

kotlin
class ContinuityActivity : AppCompatActivity() {
    private lateinit var binding: ActivityContinuityBinding
    private var itemList = mutableListOf<String>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityContinuityBinding.inflate(layoutInflater)
        setContentView(binding.root)

        val savedState = lastNonConfigurationInstance as? ContinuityState
        if (savedState != null) {
            itemList.addAll(savedState.items)
            restoreUi(savedState)
        }
        setupWindowManager()
    }

    private fun setupWindowManager() {
        val controller = WindowManager(this).screenContinuityController
        controller.registerContinuityListener { feature ->
            updateLayoutForFeature(feature)
        }
    }

    private fun updateLayoutForFeature(feature: FoldingFeature) {
        when (feature.state) {
            FoldingFeature.State.HALF_OPENED -> binding.root.enableTabletopMode()
            FoldingFeature.State.FLAT -> binding.root.enableTabletMode()
            FoldingFeature.State.TABLE_TOP -> binding.root.enableTouchpadMode()
        }
    }

    override fun onRetainNonConfigurationInstance(): Any {
        return ContinuityState(itemList.toList(), binding.listView.firstVisiblePosition)
    }
}

data class ContinuityState(
    val items: List<String>,
    val scrollPosition: Int
)

The key element is the ContinuityState class, which stores the item list and scroll position. The Activity saves it before recreation and restores it immediately after calling onCreate. The WindowManager controller subscribes to posture changes and switches the layout between modes.

Testing Continuity on Emulator and Device

Android Studio provides a foldable device emulator with support for all three postures. To test Screen Continuity, simply create a virtual device of type Pixel Fold or Samsung Galaxy Z Fold and switch postures using the emulator control panel.

Emulator Setup

Create an AVD with the Foldable category and select a 7.6-inch screen resolution. In the emulator’s extended controls, open the Folding Postures tab and switch between postures. Each switch triggers a configuration change that the app should handle correctly.

Physical Device

On a real device (Galaxy Z Fold 5, Pixel Fold), testing is done by physically folding and unfolding. Samsung DeX and Multi-Window modes also activate continuity. For debugging, use the ADB command adb shell dumpsys window policy, which displays the current fold state.

Common Issues

The main errors include RecyclerView state loss, text field content reset, and dialog window closure. ViewModel solves these problems by keeping data in memory independent of the Activity lifecycle. It is also important to annotate the Activity in the manifest with the android:configChanges parameter if the app handles changes manually.

xml
<!-- AndroidManifest.xml -->
@android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"

Frequently Asked Questions

How is Screen Continuity different from regular state saving?

Screen Continuity saves state during physical screen size changes, not just rotation. Regular onSaveInstanceState does not guarantee state preservation when switching foldable device postures, whereas ScreenContinuityController handles this specific scenario.

Which Android devices support Screen Continuity?

All foldable devices with Android 10+ and Google Play Services. Support is included in Pixel Fold, Galaxy Z Fold series, Huawei Mate X, Oppo Find N, and OnePlus Open. Requires Jetpack WindowManager version 1.1 or higher.

How does Screen Continuity work with Jetpack Compose?

Jetpack Compose supports Screen Continuity through rememberSaveable and WindowSizeClass. Composition automatically responds to WindowMetrics changes, and rememberSaveable preserves state between recompositions. The onSizeChanged modifier allows tracking size changes in real time.

What happens if Screen Continuity is not implemented?

When the device is unfolded or folded, the Activity is recreated without saving state. The user loses entered data, scroll position resets, and open dialogs close. This leads to negative reviews and a lower app rating on Google Play.

How to test Screen Continuity without a physical device?

Android Emulator supports foldable device simulation. Create an AVD of type Pixel Fold, open Extended Controls, and select the Folding Postures tab. Switching postures triggers a configuration change, allowing you to test state preservation without a physical device.

Summary

  • Screen Continuity — an Android mechanism for preserving Activity state when the physical configuration of a foldable device changes.
  • Jetpack WindowManager provides ScreenContinuityController for tracking HALF_OPENED, FLAT, and TABLE_TOP postures.
  • onRetainNonConfigurationInstance — the primary method for preserving data before Activity recreation during unfolding.
  • ViewModel and rememberSaveable in Compose solve state loss without manual lifecycle management.
  • Android Studio Emulator allows testing all foldable device postures without a physical device.
  • Ignoring Screen Continuity leads to UI reset and loss of entered data when folding.
  • It is recommended to add continuity support to all apps targeting foldable devices and tablets.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also