I wrote a start screen, and then used the delay me...
# compose
n
I wrote a start screen, and then used the delay method to launch the main screen, but I found a problem, as long as I write navController.navigate after the delay method, I need to press the return button twice to end the program, but without the delay method only need to press once to end the program, I guess it may be a problem of the delay method, how should I fix it?
Copy code
val delayedHandler = Handler()
delayedHandler.postDelayed({
    navController.navigate("mainPage") {
        popUpTo("welcome") { //delete
            inclusive = true //close stack
        }
    }
}, 2000)
but, if delayMillis is 20, its normal
s
Use LaunchedEffect to set delay . Don't make use of handlers or threads in Compose. There are various side effects that can fulfill your needs
n
omg thank you !