- OnBackPressedCallback now offers Predictive Back callbacks for handling the back gesture starting, progress during the gesture, and the back gesture being canceled, in addition to handleOnBackPressed() for when the back gesture is committed.
- PredictiveBackHandler Composable is added to handle predictive back gesture events in Activity Compose, providing a Flow of BackEventCompat objects that must be collected in the suspending lambda provided.
- ComponentActivity.enableEdgeToEdge() is added to easily set up edge-to-edge display in a backward-compatible manner.
- ComponentActivity.onBackPressed() is deprecated in favor of the APIs for handling back, and developers should use OnBackPressedDispatcher instead of overriding this method. inferred, marked in the notes below
1 change to check, marked in the notes below
From AndroidX Activity
Predictive Back - The OnBackPressedCallback now offers new Predictive Back callbacks for handling the back gesture starting, progress throughout the gesture, and the back gesture being canceled in addition to the previous handleOnBackPressed() callback for when the back gesture is committed. This also comes with the PredictiveBackHandler Composable to handle predictive back gesture events in Activity Compose. It provides a Flow of BackEventCompat objects that must be collected in the suspending lamba you provide: PredictiveBackHandler { progress: Flow -> // code for gesture back started try { progress.collect { backEvent -> // code for progress } // code for completion } catch (e: CancellationException) { // code for cancellation } } ComponentActivity.onBackPressed() has now been deprecated in favor of the APIs for handling back. Developers should now utilize the OnBackPressedDispatcher, rather than overriding this method. EdgeToEdge - ComponentActivity.enableEdgeToEdge() has been added to easily set up the edge-to-edge display in a backward-compatible manner. deprecated · inferred