How do you get/set media volume (not ringtone volume) in Android?

前端 未结 8 1865
青春惊慌失措
青春惊慌失措 2020-12-01 00:01

Is there a way to get/set media volume? I have tried the following:

AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int currentV         


        
8条回答
  •  臣服心动
    2020-12-01 00:34

    You can set your activity to use a specific volume. In your activity, use one of the following:

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    this.setVolumeControlStream(AudioManager.STREAM_RING);  
    this.setVolumeControlStream(AudioManager.STREAM_ALARM);  
    this.setVolumeControlStream(AudioManager.STREAM_NOTIFICATION);  
    this.setVolumeControlStream(AudioManager.STREAM_SYSTEM);  
    this.setVolumeControlStream(AudioManager.STREAM_VOICECALL); 
    

提交回复
热议问题