It seems Jetpack Compose Button click has no default sound. How can I add the standard CLICK sound to button clicks?
It seems Jetpack Compose Button click has no default sound. How can I add the standard CLICK sound to button clicks?
I tried this answer and worked...
Can't play sound on button click using playSoundEffect(SoundEffectConstants.CLICK)
val context = AmbientContext.current
...
OutlinedButton(
content = { Text("OK") },
onClick = {
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
audioManager.playSoundEffect(SoundEffectConstants.CLICK,1.0f)
}
)