Reputation: 11
I am creating an app for Android devices that allows you to use your microphone like Siri but I am having trouble with the annoying microphone activation and deactivation beep sound. I can mute the beep sound, however, it mutes my notification and call volume control, as new devices place the notification and call volume as one setting. Is there a way to disable the beep sound without altering the device sound controls?
Here is what I am using:
@RequiresApi(api = VERSION_CODES.M)
private void muteBeepSoundOfRecorder() {
AudioManager amanager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if (amanager != null) {
amanager.adjustStreamVolume(AudioManager.STREAM_NOTIFICATION, AudioManager.ADJUST_MUTE, 0);
amanager.adjustStreamVolume(AudioManager.STREAM_SYSTEM, AudioManager.ADJUST_MUTE, 0);
}
}
and on my start command I used a try and catch as the following:
try {
((AudioManager) Objects.requireNonNull(
getSystemService(Context.AUDIO_SERVICE))).setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
} catch (Exception e) {
e.printStackTrace();
}
Nothing seems to work to turn off the beep sound without muting the phone settings.
Upvotes: 1
Views: 234