Trigger system volume bar

前端 未结 2 1957
生来不讨喜
生来不讨喜 2021-01-23 23:41

Is it possible by pressing a button in my Activity to make the volume bar appear? The volume bar is the view that appears when you press one of the hardware volume

相关标签:
2条回答
  • 2021-01-24 00:14

    if you call setStreamVolume, pass the flag FLAG_SHOW_UI See http://developer.android.com/reference/android/media/AudioManager.html#FLAG_SHOW_UI

    0 讨论(0)
  • 2021-01-24 00:25

    Working code

    AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                        AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
    
    0 讨论(0)
提交回复
热议问题