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.
Related
I am making an application that uses the "Assets audio player" library to play background music for the application. The problem I have is that the sound of the application is affected by the wireless headset. If I take out a headset (left or right) the app's sound is paused, and when I put the headset in my ear, the sound won't continue.
Is there a way I can disable this or is there a way to prevent headphones from affecting the app's sound?
Please give me the solution.
Thank you so much!
In Android, it is possible to mute the microphone with:
AudioManager.setMicrophoneMute(boolean mute)
However, this method mutes the microphone for the whole device and not just the application.
As an AOSP developer, is it possible to mute the microphone only for an application and not on the whole device. I know it should be possible.
I am developing an Android alarm clock app and I am using the STREAM_ALARM for playing the alarm audio. When I plug in headphones during the alarm playing the audio, the audio starts playing in the headphones but also continues playing in the speaker.
But I want to silence the speaker so that the user can plug in his headphones and continue listening to the audio without interrupting any people around him. This might be unusual behavior, but it's very important for this specific alarm clock app.
Maybe I could use STREAM_MUSIC, but:
The docs say that Unless your app is an alarm clock, you should play audio using the STREAM_MUSIC stream.
If the alarm starts ringing and headphones are already plugged in, I do need it to play through the speaker. STREAM_MUSIC does not do this. There might be workarounds, but I need this 100% reliable, so it'd be better to make a workaround for silencing the speaker when needed than a workaround for making it loud when needed.
I am not sure what other consequences it might have, it doesn't seem safe.
So, is there any option to force the speaker to be silent? Using some reflection maybe?
I was also considering changing the stream type on the ActionHeadsetPlug to STREAM_MUSIC, but it requires stopping the audio, recreating the MediaPlayer instance, seeking to the previous position, rebinding any events, other logic etc.. a lot of work for my use case. Silencing the speaker would definitely be better if it's possible.
I work with AOSP 4.4.2 build. We'd like to mute downlink voice call sound for a while. How can we that? We already test with AudioManager's setStreamMute, setStreamVolume, but it was not working on our projects.
Like a mute a camera shutter sounds, we now finding some solution on audio_policy.
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