2011-09-07 64 views
0

我使用此代码播放声音。你如何改变声音的输出音量?

我想让用户能够改变声音的音量。你能告诉我如何做到这一点?

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

谢谢。

诚然, 伊马德

回答

2

使用

notification.audioStreamType = AudioManager.STREAM_MUSIC; 

    context.setVolumeControlStream(AudioManager.STREAM_MUSIC); 
+0

Nammari嗨,感谢您的快速答复。你能告诉我如何将音量改为50%吗?真的,埃马德 –

+0

嗨Nammari,我还发现,当我键入上下文后setVolumeControlStream不是在智能感知和Eclipse中显示错误,说:“方法setVolumeControlStream(INT)是未定义的类型上下文” –

+0

如果UA在活动中使用this.setVou ..... – confucius