1

I need to set speakerphone volume to the lowest possible through Audio Manager. I need the lowest volume index.

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

audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
                             [int value] = ?,
                             0);

I did a search on SO, but found nothing usefull.

winchester
  • 65
  • 2
  • 12
  • for what you need to low the volume for example For Audio or for Call.? – Rajan Bhavsar Jun 12 '15 at 11:52
  • possible duplicate of [Setting the Android System Volume](http://stackoverflow.com/questions/9164347/setting-the-android-system-volume) – moffeltje Jun 12 '15 at 11:52
  • for call, my app turn on the speaker and sets the volume to lowest so user can listen conversation very clearly if he/she have bad mic – winchester Jun 12 '15 at 11:53

3 Answers3

1
private AudioManager audio;

Inside onCreate:

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

Override onKeyDown:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
    audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
            AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
    return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
    audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
            AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
    return true;
default:
    return false;
}
}
Rajan Bhavsar
  • 1,977
  • 11
  • 25
0

you can do it by the below code

audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                    AudioManager.ADJUST_LOWER, 0);
SAM
  • 399
  • 2
  • 9
0
audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
        AudioManager.ADJUST_LOWER, 
        AudioManager.FLAG_SHOW_UI);
Ziem
  • 6,579
  • 8
  • 53
  • 86
Deepanshu Gandhi
  • 490
  • 3
  • 10