BackHandler¶
You can use BackHandler to detect the presses on the device back button inside of Compose
Example¶
@Composable
fun BackHandlerExample() {
var backPressedCount by remember { mutableStateOf(0) }
BackHandler(enabled = true, onBack = {
backPressedCount += 1
})
Text(text="Backbutton was pressed : $backPressedCount times")
}
See also:¶
Last update: September 7, 2024