mariosangiorgio
mariosangiorgio

Reputation: 5543

How can I increase the maximum ringtone value?

I use the Ringtone class to play an alarm when some events occur in an application I'm writing.

Everything works perfectly but for the issue that even if I set the volume to maximum (from the phone interface) it is still a little too low. Can I programmatically set a louder volume?

Upvotes: 0

Views: 972

Answers (2)

HappyDump
HappyDump

Reputation: 453

Try to use the AudioManager Class:

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume (AudioManager.STREAM_MUSIC,audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);

Hope I could help.

Upvotes: 1

Jeffy Lazar
Jeffy Lazar

Reputation: 1923

You can use the following snippet, using AudioManager:

AudioManager am = 
    (AudioManager) getSystemService(Context.AUDIO_SERVICE);

am.setStreamVolume(
    AudioManager.STREAM_MUSIC,
    am.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
    0);

This sets the volume to the maximum level (getStreamMaxVolume()) for the STREAM_MUSIC (which is on example a song played). For other types of sounds, use different value, like STREAM_RING etc.

Upvotes: 1

Related Questions