问题
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
回答1:
use
notification.audioStreamType = AudioManager.STREAM_MUSIC;
context.setVolumeControlStream(AudioManager.STREAM_MUSIC);
来源:https://stackoverflow.com/questions/7337481/how-do-you-change-the-output-volume-of-a-sound