When I press one of the volume hardware buttons, Android's system
is shown a depicted. Naturally this also happens when I press whithin my app.
Is it possible to configure the style of these Android system stuff like volume? Or at least when I open these system stuff in my app?
EDIT: As recommended in the comments, I've overwritten onKeyDown, but the adjustStreamVolume switches between 0 and 1 only.
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (event?.keyCode) {
KeyEvent.KEYCODE_VOLUME_UP -> {
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE)
return true
}
KeyEvent.KEYCODE_VOLUME_DOWN -> {
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE)
return true
}
else -> {
return super.onKeyDown(keyCode, event)
}
}
}
The streamVolume does not increase well. Unfortunately, when I press continuously Volume_up, the 'getStreamVolume()' value remains t 1