AndroidX Activity 1.8.0-alpha07

1.8.0-alpha07
Added 2
  • Added a new PredictiveBackHandler Composable in Activity Compose to handle predictive back gesture events, providing a Flow of BackEventCompat objects that must be collected in the provided suspending lambda
  • Added a compile time lint rule that warns when the Flow passed to PredictiveBackHandler does not call collect()
Changed 2
  • The onBackPressedDispatcher in ComponentActivity is now initialized lazily so that it is only created when required
  • Removed usages of the experimental isAtLeastU() API
Fixed 1
  • ComponentActivity no longer throws a NullPointerException on Android 13 when it receives an onBackPressed() callback after the Activity has already been destroyed

From AndroidX Activity

Activity Compose has added a new PredictiveBackHandler Composable to handle predictive back gesture events. 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 } } It also comes with a compile time warning via lint rule to ensure the Flow calls collect(). ( Id2773, b/294884345) The onBackPressedDispatcher in ComponentActivity is now initialized lazily so that it is only created when required. ( I0bf8e) ComponentActivity will no longer show a NPE on Android 13 when it gets an onBackPressed() callback and the Activity has already been DESTROYED. ( Idb055, b/291869278) Removed usages of experimental isAtLeastU() API ( Ie9117, b/289269026)

View original

Upgraded? How did it go?

Discussion