Question

Does anybody know if there is a way to set incoming call ringtone volume increasing from low to high programmatically from Android application? Any suggestions are appreciated.

Was it helpful?

Solution 2

You could call to getStreamMaxVolume(RingTone) to get your max volume of the ring tone.

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

Now you have your max volume.

Then you could make some method to change the volume (with a timer, loop, random, ...)

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

OTHER TIPS

You need to use AudioManager
Try this:

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume (AudioManager.STREAM_MUSIC,audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top