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.and some code from service:
ServiceStart:
Servicedestroy()
OnDestroy()