控制音量键调整的声音类型

andoid 声音分成了好几类,最常用到的就是 通话声音  多媒体声音(音乐)

 

就目前的经历,如果activity时用MediaPlayer类播放着音乐的话,音量键默认调整的声音类型的 多媒体。否则默认控制的是 通话声音。

 

若activity 未播放音乐也要改变的是  多媒体 声音的话,则可在onCreate里执行如下函数即可。

setVolumeControlStream(AudioManager.STREAM_MUSIC);

---------------------- 更详细的见 SDK ---------------------------------

public final void setVolumeControlStream(int streamType)

Since:

Suggests an audio stream whose volume should be changed by the hardware volume controls.

The suggested audio stream will be tied to the window of this Activity. If the Activity is switched, the stream set here is no longer the suggested stream. The client does not need to save and restore the old suggested stream value in onPause and onResume.

Parameters
streamType The type of the audio stream whose volume should be changed by the hardware volume controls. It is not guaranteed that the hardware volume controls will always change this stream's volume (for example, if a call is in progress, its stream's volume may be changed instead). To reset back to the default, use .
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值