Turn off microphone in android - android

I want to turn off or disable the microphone during a call.
I searched, but I got almost nothing. Some people say it is not possible in android.
How do I turn off the microphone?

You can't completely disable the microphone. But you can play around the audio manager, to mute it etc...
AudioManager

Related

Losing Audio while connect to Bluetooth SCO

I know this is a very specific issue, but I'm hoping someone else has some insight.
I am using a third Party TTS (Text to Speech) and ASR (Auto Speech Recognition) library from Cerence. I've noticed on Android 12, and some Android 11 devices, when I use them together is will shut down the Audio output. I can still use the ASR for input, but no audio will be played.
I'm not seeing much in the logs for this, but when this happens, I need to disconnect the BT headset and reconnect it.
In minimal testing, Shortly after enabled Bluetooth SCO, the Audio is lost on Android 12.
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// Need to set mode so we continue to get the Audio in the BT headset.
am.setMode(AudioManager.MODE_IN_COMMUNICATION);
am.startBluetoothSco();
A similar thing happens on Android 11, but while I can make it fail reliably, I don't know a precise way to make it happen.
I'm wondering if anyone has any insight on how to debug audio issues. Is there certain logs I can pull or look for? Is there someway I can troubleshoot audio issues? When this happens I can't play audio in any way, as an example YouTube no longer has audio in the headset. So either the audio is being redirected somewhere else, or it has crashed.
I'm also wondering if there is another way to take control of the mic outside of Bluetooth SCO, or if there is a SCO setting I should be using that acts differently.
UPDATE:
In more testing I've realized that the AudioManager mode is being changed by something from MODE_IN_COMMUNICATION to NORMAL. I have not figures out why yet, but if I keep forcing the mode to MODE_IN_COMMUNICATION, my audio continues to be played.

Bluetooth speaker programming

i want to know if it is possible that when you connect to Bluetooth speaker by A2dp you can play your desired sound and other sound not be played like sounds of Sms,notification,...?
Well, the only possible way is for you to turn off all kinds of notification sounds and reactions on your device, otherwise it will interfere.

Android - How to disable sound on video recording start?

On Android when you start recording video in your app there is a notification sound. Is there a reliable way to disable it?
For non-rooted devices, if the firmware allows muting that sound, you can mute it by using AudioManager.setStreamMute() on STREAM_MUSIC (or STREAM_SYSTEM on some devices) before recording and unmute when recording starts. It won't work if the firmware doesn't allow this. In this case, there is no way to disable it other than rooting it.

How to bring audio from microphone to speaker on Android?

My problem is when I talk into the microphone, I want my sound to go to speaker of the phone which has Android OS. I think "MediaPlayer" class can't do it. Do you have any way?
Here you are not clear in which scenario you are going to do this but however it is possible to do using AudioManager, you can set your modes and audio services. For more details refer this link :
AudioManager

mute sound through phone speaker Android api

I want the to mute all sounds coming through the phone speaker but keep the sounds going through the headphones. Is this possible?
I was looking at:
setMicrophoneMute(true);
and
setSpeakerphoneOn(false);
but neither seem to have any affect. Is this even possible? I have this permission in my manifest:
I couldn't see any methods that would accomplish what I want in the audio manager but maybe I just don't understand the api.

Categories

Resources