how to increase and decrease the volume programmatically in android

后端 未结 7 1148
余生分开走
余生分开走 2020-12-08 22:54

I created the music player app and i want to set the volume up/down programmatically .

I want to implement two another

7条回答
  •  情书的邮戳
    2020-12-08 23:05

    This code will set the volume 100 instantly with no feedback to the user when buttonSES is pressed.

    public void perform_actionSES(View v) {
    Button buttonSES = (Button) findViewById(R.id.buttonSES);
    
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 100, 0);  
    }
    

提交回复
热议问题