Emad-ud-deen
Emad-ud-deen

Reputation: 4864

How do you change the output volume of a sound?

I'm using this code to play a sound.

I would like to give the user the ability to alter the volume of the sound. Can you tell me how to do this?

NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.sound = Uri.parse("android.resource://emad/raw/quarter");

Thanks.

Truly, Emad

Upvotes: 0

Views: 1245

Answers (1)

confucius
confucius

Reputation: 13327

use

  notification.audioStreamType = AudioManager.STREAM_MUSIC;

  context.setVolumeControlStream(AudioManager.STREAM_MUSIC);

Upvotes: 2

Related Questions