我想改变ringertonevolume的音量 [英] I want change the volume of ringertonevolume

查看:404
本文介绍了我想改变ringertonevolume的音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个code键调节音量,但没有奏效。

  INT体积= 23;
audio.setStreamVolume(AudioManager.STREAM_RING,体积,AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_ALLOW_RINGER_MODES);}
 

解决方案

你不应该只是在音量设置为23,而不是你应该先打电话到getStreamMaxVolume(StreamType),以获得最大音量可能会将streamType在这个情况是铃声的音量。

例如,对铃声的音量设置到最大,你这样做!

  audioManager.setStreamVolume(AudioManager.STREAM_RING,audioManager.getStreamMaxVolume(AudioManager.STREAM_RING),FLAG_ALLOW_RINGER_MODES | FLAG_PLAY_SOUND);
 

更新

  INT streamMaxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
    Toast.makeText(这一点,Integer.toString(streamMaxVolume),Toast.LENGTH_LONG).show(); //我得到了7
    audioManager.setStreamVolume(AudioManager.STREAM_RING,streamMaxVolume,AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND);
 

确定。现在我在家里我可以尝试codeS。在这里你可以看到,streamMaxVolume给我的7一整数,如果你尝试将其设置为23的方式太多了。所以在我的情况下,你可以在setStreamVolume使用的可能值是

0,1,2,3,4,5,6,7 最低< ----->最高

  //设置为最低 - >
audioManager.setStreamVolume(AudioManager.STREAM_RING,0,AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND);

//设置为最响亮 - >
audioManager.setStreamVolume(AudioManager.STREAM_RING,7,AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND);
 

i used this code to adjust volume but it didn't work

int volume=23;
audio.setStreamVolume(AudioManager.STREAM_RING,volume, AudioManager.FLAG_PLAY_SOUND|AudioManager.FLAG_ALLOW_RINGER_MODES);}

解决方案

you should not just set the volume to 23 instead you should first make a call to getStreamMaxVolume(StreamType) to get the max volume possible for the StreamType which in this case is the ringer's volume.

for example, to set the ringer's volume to max you do this!

audioManager.setStreamVolume(AudioManager.STREAM_RING, audioManager.getStreamMaxVolume(AudioManager.STREAM_RING), FLAG_ALLOW_RINGER_MODES|FLAG_PLAY_SOUND);

UPDATES

    int streamMaxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
    Toast.makeText(this, Integer.toString(streamMaxVolume), Toast.LENGTH_LONG).show(); //I got 7
    audioManager.setStreamVolume(AudioManager.STREAM_RING, streamMaxVolume, AudioManager.FLAG_ALLOW_RINGER_MODES|AudioManager.FLAG_PLAY_SOUND);

ok. now that i am at home i can try out codes. here as you can see, streamMaxVolume gives me a integer of 7. if you try to set it to 23 its way too much. so the possible values you can use in setStreamVolume in my case is

0, 1, 2, 3, 4, 5, 6, 7 Lowest <-----> Highest

//set to lowest ->
audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_ALLOW_RINGER_MODES|AudioManager.FLAG_PLAY_SOUND);

//set to loudest ->
audioManager.setStreamVolume(AudioManager.STREAM_RING, 7, AudioManager.FLAG_ALLOW_RINGER_MODES|AudioManager.FLAG_PLAY_SOUND);

这篇关于我想改变ringertonevolume的音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆