我想改变ringertonevolume
问题描述:
我用这个代码来调整音量的音量,但没有奏效我想改变ringertonevolume
int volume=23;
audio.setStreamVolume(AudioManager.STREAM_RING,volume, AudioManager.FLAG_PLAY_SOUND|AudioManager.FLAG_ALLOW_RINGER_MODES);}
答
你不应该只是在音量设置为23,而不是你应该首先作出getStreamMaxVolume通话(流类型),以获得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(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);
确定。现在,我在家里,我可以尝试代码。在这里,你可以看到,streamMaxVolume给了我一个整数7.如果你试图将它设置为23太多。因此可以在setStreamVolume使用的可能值在我的情况是
0,1,2,3,4,5,6,7 最低< ----->最高
//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);
“没不工作“不是一个非常有用的描述。有没有错误信息?编辑您的问题以包含更多信息。 – Emyr 2011-05-11 13:09:50