androidandroid-jetpack-composeandroid-14predictive-back

Android 14 predictive back gesture - blinking white background color


According to the docs, we simply should update 'androidx.activity:activity' version in the build.gradle and add android:enableOnBackInvokedCallback="true" to the Manifest to make predictive back work. I made both changes, the animation works in general, but the screen is blinking white while transitioning from my Activity Two to Activity One. I believe it's something like a global background of the app, however, android:windowBackground is dark in both activities. Both activities are ComponentActivity and the UI is Jetpack Compose based (there are no Composables with white background). What have I missed?

enter image description here

Update: I created a new project with two activities:

class Activity1 : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            Box(modifier = Modifier.fillMaxSize().background(Color.Black)) {
                Button(onClick = {
                    startActivity(Intent(this@Activity1, Activity2::class.java))
                }) {
                    Text(text = "TO ACTIVITY 2", color = Color.White)
                }
            }
        }
    }
}

class Activity2: ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            Box(modifier = Modifier.fillMaxSize().background(Color.Black)) {

            }
        }
    }
}

the theme for both activities is:

<style name="Theme.PredBackTest" parent="android:Theme.Material.Light.NoActionBar">
    <item name="android:windowBackground">@android:color/black</item>
</style>

however, the result is same - it's blinking white while moving back from Activity2 to Activity1.


Solution

  • You need to update your theme android:Theme.Material.DayNight