当开发多媒体应用或者游戏应用的时候,需要使用音量控制键来设置程序的音量大小。在Android系统中有多中音频流,通过Activity中的函数 setVolumeControlStream(int streamType)可以设置该Activity中音量控制键控制的音频流,一般在onCreate函数中设置。
Android中有如下几种音频流:
•AudioManager.STREAM_MUSIC /** The audio stream for music playback */
•AudioManager.STREAM_RING /** The audio stream for the phone ring */
•AudioManager.STREAM_ALARM /** The audio stream for alarms */
•AudioManager.STREAM_NOTIFICATION /** The audio stream for notifications */
•AudioManager.STREAM_SYSTEM /** The audio stream for system sounds */
•AudioManager.STREAM_VOICECALL /** The audio stream for phone calls */
setVolumeControlStream函数描述:
void android.app.Activity .setVolumeControlStream(int streamType)
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 AudioManager.USE_DEFAULT_STREAM_TYPE .
音量控制键控制的音频流(setVolumeControlStream)描述
2021-01-03 16:18Android教程网 Android
当开发多媒体应用或者游戏应用的时候,需要使用音量控制键来设置程序的音量大小,在Android系统中有多种音频流,感兴趣的朋友可以了解下
延伸 · 阅读
- Android
Android中扫描多媒体文件操作详解
这篇文章主要介绍了Android中扫描多媒体文件操作详解,本文讲解了Android中的多媒体文件扫描机制、如何扫描一个刚创建的文件、如何扫描多个文件,需要的朋...
- Android
Android控件系列之CheckBox使用介绍
CheckBox和Button一样,也是一种古老的控件,它的优点在于,不用用户去填写具体的信息,只需轻轻点击,缺点在于只有“是”和“否”两种情况,但我们往...
- Android
Android开发笔记之:对实践TDD的一些建议说明
本篇文章是对Android中实践TDD的一些建议进行了详细的分析介绍,需要的朋友参考下...
- Android
Android编程中EditText限制文字输入的方法
这篇文章主要介绍了Android编程中EditText限制文字输入的方法,涉及Android针对EditText的监听技巧,具有一定参考借鉴价值,需要的朋友可以参考下...
- Android
浅谈Android系统的基本体系结构与内存管理优化
这篇文章主要介绍了Android系统的基本体系结构与内存管理优化,非常简洁明了地总结了系统服务及垃圾回收等安卓的一些主要特性,需要的朋友可以参考下...
- Android
使用RadioButton+Fragment实现底部导航栏效果
这篇文章主要为大家详细介绍了使用RadioButton+Fragment实现底部导航栏效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...
- Android
Android Animation实战之屏幕底部弹出PopupWindow
这篇文章主要为大家介绍了Android Animation动画实战项目,屏幕底部弹出PopupWindow,如何实现?文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的...
- Android
解析Android应用程序运行机制
这篇文章主要介绍了Android应用程序运行机制,有需要的朋友可以参考一下...