2

I am working in an android app and I need to make an optionMenu with an option to disable/enable the sounds in the app.

Is it possible in android have full control over the volume of the app? Is there any method that could do that? Must I do this with code?

Thanks

Anthony Graglia
  • 5,355
  • 5
  • 46
  • 75
Mun0n
  • 4,438
  • 4
  • 28
  • 46

2 Answers2

1

You can find useful information here. According to that answer, it's not possible. Just don't play the sounds.

Community
  • 1
  • 1
mdelolmo
  • 6,417
  • 3
  • 40
  • 58
1

By using AudioManager you can get current volume level and max volume level. At the time of button click/ option select you can control the volume level also. Here is the code.I hope this will help you to set volume.

AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
int curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);

To Set Volume

audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,vol_level, 0);
Finder
  • 1,217
  • 5
  • 18
  • 46