I am creating an application and I want to turn off the sound and turn on the sound of this application. I found this code to mute:
AudioManager aManager=(AudioManager)getSystemService(AUDIO_SERVICE);
aManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
It mutes the sound of the entire device and disables the device settings for sound settings, not just the sound of the application. And I found this code to turn on the sound:
AudioManager aManager=(AudioManager)getSystemService(AUDIO_SERVICE);
aManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
When I turned off the sound and I pressed the button containing this code, this code does not work, and the sound setting of my device is still turned off. I just want to turn off the sound and turn on the sound of my application, not my device. Any correction?
source
share