Mun0n
Mun0n

Reputation: 4437

Audio control in Android app

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

Upvotes: 2

Views: 1649

Answers (2)

Finder
Finder

Reputation: 1217

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);

Upvotes: 1

mdelolmo
mdelolmo

Reputation: 6447

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

Upvotes: 1

Related Questions