Reputation: 245
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.
Upvotes: 1
Views: 7619
Reputation: 11830
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);
Upvotes: 1
Reputation: 3506
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);
Upvotes: 3