振铃期间更改铃声音量 [英] Changing ringer volume during ringing

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

问题描述

我想振铃过程中更改铃声音量。 code振铃(它是在系统设置更改)在下面设置它,但它不来与实际的振铃效应(只剩下一环调用将使用新的值)。我可以强制使用的变化,使他们立即生效?

  AudioManager音频=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
audio.setStreamVolume(AudioManager.STREAM_RING,体积,AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND);
 

解决方案

在一些研究和测试,我发现体积变化可能只在进来的呼叫检测的非常早期的阶段。这是至关重要不是做的onReceive()方法内多操作。

I'd like to change the ringer volume during ringing. Code below sets it during ringing (it is changed in system settings) but it doesn't come to effect with actual ringing (only the next ring call will use new value). Can I force this changes to make them effect Immediately?

AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);    
audio.setStreamVolume(AudioManager.STREAM_RING, volume, AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND);

解决方案

After some research and tests I've found that volume change is possible only in very early stage of incomming call detection. It's vital not to do much operations inside the onReceive() method.

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

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