Search code examples
androidandroid-audiomanager

AudioManger FLAG_SHOW_UI not showing the system volume menu in Samsung devices


AudioManager ad = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (ad != null) {
        ad.adjustVolume(AudioManager.STREAM_MUSIC,AudioManager.FLAG_SHOW_UI);
    }

This code doesn't showing volume menu in Samsung devices. Tried with Galaxy S10,A71


Solution

  • For your case STREAM_MUSIC you need to use like below code -

    AudioManager audio = (AudioManager)getSystemService(Context.AUDIO_SERVICE); 
    audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
    

    Hope this will help you.