Android(安卓)获取系统音量
16lz
2021-12-12
关于Android获取系统音量值的文章在网上随便一搜就一大堆,我在此再整理只是为了更方便与学习,相当于做笔记吧。
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); max = am.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);// 0 current= am.getStreamVolume(AudioManager.STREAM_VOICE_CALL); Log.e("service", "通话音量值:" + max + "-" + current); max = am.getStreamMaxVolume(AudioManager.STREAM_SYSTEM);// 1 current = am.getStreamVolume(AudioManager.STREAM_SYSTEM); Log.e("service", "系统音量值:" + max + "-" + current); max = am.getStreamMaxVolume(AudioManager.STREAM_RING);// 2 current = am.getStreamVolume(AudioManager.STREAM_RING); Log.e("service", "系统铃声值:" + max + "-" + current); max = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);// 3 current = am.getStreamVolume(AudioManager.STREAM_MUSIC); Log.e("service", "音乐音量值:" + max + "-" + current); max = am.getStreamMaxVolume(AudioManager.STREAM_ALARM);// 4 current = am.getStreamVolume(AudioManager.STREAM_ALARM); Log.e("service", "闹铃音量值:" + max + "-" + current); max = am.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION);// 5 current = am .getStreamVolume(AudioManager.STREAM_NOTIFICATION); Log.e("service", "提示声音音量值:" + max + "-" + current); // ------还可以通过动态设置音量值的大小,方法如下: // public void setStreamVolume(int streamType, int index, // int flags); // streamType以上几种模式中的一种, // index:设置音量的大小 // flags:标志位,不太清楚做什么的。
更多相关文章
- Android模拟器分辨率介绍
- android style
- Android获取屏幕宽高、屏幕密度、手动计算view大小
- Android预定义样式
- Android中文API(142) —— Gravity
- 三、安卓UI学习(1)
- android Dialog大小修改
- Android系统配置数据库注释(settings.db)
- android style