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.
Related
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.
I'm working on a diagnosis app for android, I want to test whether the speakers are working fine or not. I thought the way to do this is to play a sound and check whether the speakers are playing the audio or not. I looked for code but didn't find anything useful. How can this be achieved in android? Is there a better way to do the same thing?
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
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
I'm working on a music app which consists in a Service playing music while other apps are running.
In order to enjoy the music and only the music, the Service mutes all the other apps. In order to do that, it mutes STREAM_MUSIC and play music over STREAM_VOICE_CALL (found that solution to mute other apps here)
As the Service uses STREAM_VOICE_CALL to play music, what I'm trying to find is a way to make the volume buttons control this stream when a sound is playing.
What I already tried:
setVolumeControlStream: only works in Activities
Capturing volume keys pressed events: Services do not receive such events (source)
audioManager.setMode(AudioManager.MODE_IN_CALL) : does not work in my case. Plus, the SDK documentation states that this "mode should only be used by the telephony application when it places a phone call".
At this point, I'm out of options and any help would be appreciated. Thanks!
I would personally not suggest you to STREAM_VOICE_CALL as it is meant to be recommended to use it for Voice calls as compared to media playback. Using this may prevent you from using features exposed by Android for media playback.
Having said this & taking into consideration your use-case, I think you need to look for changing 'call volume' level as compared to 'media volume' level.
Have a look at the MediaPlaybackService.java as used in the stock Music Player app and try to customize it as per your needs.
I havn't tried it myself. but looks like it should work. Kindly try it out.
m_audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
m_audioManager.setMode(AudioManager.MODE_IN_CALL);