2013-04-23 108 views
1

有谁知道是否有办法将来电铃声音量从低到高设置为从Android应用程序编程增加? 任何建议表示赞赏。如何增加Android应用的铃声音量从低到高

+1

哪里是你的代码?你有什么尝试? – 2013-04-23 11:31:36

+0

其实,我没有它,因为我不确定这样的功能是否可以在Android应用程序中实现。 – Dubrovin 2013-04-23 11:46:26

回答

1

你可以打电话给getStreamMaxVolume(铃声),以获得铃声的最大音量。

int streamMaxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING); 
    Toast.makeText(this, Integer.toString(streamMaxVolume), Toast.LENGTH_LONG).show(); 

现在你有你的最大音量。

然后,你可以做一些方法来改变音量(用定时器,循环,随机,...)

audioManager.setStreamVolume(AudioManager.STREAM_RING,**YOURVOLUMEHERE**, 
AudioManager.FLAG_ALLOW_RINGER_MODES|AudioManager.FLAG_PLAY_SOUND); 
3

您需要使用AudioManager
试试这个:

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); 
audioManager.setStreamVolume (AudioManager.STREAM_MUSIC,audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0); 
相关问题