Numair
Numair

Reputation: 1062

sound on/off in an app using radio button

I am working on a game, and want to switch sound to on and off using radio button. The sounds are running in my app in other options. when sound off radio button is pressed it should mute the sound until and unless sound on pressed. Can anyone help me out to solve this issue?

Thanks in advance

Upvotes: 0

Views: 1504

Answers (2)

user3349113
user3349113

Reputation: 26

To disable sound you set it to True. To re enable sound, you set it to false. You can have a button for each or a toggle button.

Upvotes: 0

Andrew
Andrew

Reputation: 8110

Try

AudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);

..this should mute the default music stream. Pass in false to enable it again.

Upvotes: 1

Related Questions