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,205
  • 5
  • 43
  • 74
Mun0n
  • 4,397
  • 4
  • 26
  • 45

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,357
  • 3
  • 39
  • 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,207
  • 5
  • 17
  • 46