Search code examples
androidringtoneandroid-audiomanager

How to increase ringtone volume from low to high from Android application


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.


Solution

  • 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);