I do the following test:
Call from android app phone to home phone, first speak from (android phone - > home phone), in the same call speak from (home phone-> android phone).
The voice (android phone - > home phone) sounds in good volume (10/10 volume). But the voice (home phone-> android phone) sounds very low (4/10 volume).
I do the same test with random call recording app in play store The voice (android phone - > home phone) sounds in good volume (10/10 volume). The voice (home phone-> android phone) sounds in good volume (10/10 volume)
I try to call record which:
1)
audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
2)
audioRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION)
3)
audioRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL)
With 1, 2 o 3 results are very similar.
I also try to up VOICE_CALL stream if AudioSource.VOICE_CALL is used like this:
audioManager manager = (AudioManager) ServiceClass
.getServiceContext()
.getSystemService(Context.AUDIO_SERVICE);
manager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
manager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL),
AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
Does the application I have tried in the Play Store process the audio in some way to turn up the volume?
I don´t show here audio quality set code because in both test (my app test, play store app test) the audio (android phone - > home phone) sounds exactly the same, the problem is (home phone-> android phone)
I would try adjusting mic sensitivity in your code.
Heres a link to another stackoverflow quesiton being answered to do this.
How to adjust microphone sensitivity while recording audio in android - Solved
Related
My app plays and records wildlife sounds. It can do both either using external or internal hardware.
Yet, if I have a MIC with MIC ONLY functionality plugged, my app tries to play sound through it, like if it were a headset (with speakers).
How can my app decide that there is a MIC ONLY thing plugged, and ask it to play sound through either bluetooth or external speakers? I don't want a BroadcastReceiver thing necessarily, since the MIC may be plugged before I start the app.
In my phone (Android 12 Galaxy Note 10 lite), when I plug such a MIC, it shows as "Media output" a "Headset", despite the MIC has no earbuds/speaker. Yet, if the phone rings, it plays the sound through the phone speakers, as it should. So the phone knows something that I don't.
What I did was to add this code to have an idea of the mics plugged:
List<MicrophoneInfo> allmics = mAudioManager.getMicrophones();
for (MicrophoneInfo mic : allmics) {
if(mic.getType() == 3)
mAudioManager.setSpeakerphoneOn(true);
android.util.Log.e("########### AVE",mic.getType()+" "+mic.getDescription()+" "+mic.getLocation()+" "+mic.getId());
}
And this is what I got in the LogCat:
########### AVE: 15 builtin_mic1 0 9
########### AVE: 15 builtin_mic2 0 11
########### AVE: 25 15 3 15
########### AVE: 3 h2w12509 3 12509
The first two are the builtin mics of course. I have no idea what the third one is (TYPE_REMOTE_SUBMIX), but it seems some sistem thing. The forth one is my external MIC ONLY. Yet, its type (3) is TYPE_WIRED_HEADSET. So my app thinks it is a headset, which is not.
As you can see, I tried with
mAudioManager.setSpeakerphoneOn(true);
in the above loop if a TYPE_WIRED_HEADSET is detected in the above loop, without luck: still no sound. I have <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> in the manifest.
Yet, if I also add
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
as suggested here, it does work. mAudioManager.setMode(AudioManager.MODE_NORMAL) does not...
Is this the only solution?
I am using the logic from Android : Switching audio between Bluetooth and Phone Speaker is inconsistent to switch output between earpiece, speaker, and bluetooth. Here is the code:
//For BT
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
mAudioManager.startBluetoothSco();
mAudioManager.setBluetoothScoOn(true);
//For phone ear piece
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
mAudioManager.stopBluetoothSco();
mAudioManager.setBluetoothScoOn(false);
mAudioManager.setSpeakerphoneOn(false);
//For phone speaker(loadspeaker)
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mAudioManager.stopBluetoothSco();
mAudioManager.setBluetoothScoOn(false);
mAudioManager.setSpeakerphoneOn(true);
This logic works as expected as long as no other application has used audio (media player, phone, etc.). If I run my application after running the other application, the logic goes haywire. The audio still works except the destination output is not what is expected. For example, instead of speakerphone, the output may go to earpiece.
Note that I run my application after quitting from the other application. There is no overlap.
It appears audio manager settings are not specific to an application and may mess up other applications. I am wondering if there is a way to reset audio manager before setting my mode. Regards.
In my Android app, the user gets to specifically select the audio output between internal speakers and earphone. Here is my routine to turn the speaker phone on:
static void useSpeaker(Context ctx) {
AudioManager am = (AudioManager)ctx.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_NORMAL);
am.setSpeakerphoneOn(true);
}
Once the audio is set to speakers, even if you plug in the earphone, the output still goes through the speaker. I have verified on a number of different tablets and phones that this logic works.
However, on one device, once the earphone is plugged in, the audio output automatically switches from speakers to earphone.
I am wondering if there is something else that I need to take care of in the code. Or, is it just this device ignoring my directive? Regards.
Im trying to build an app that can enable or disable the headphone jack on my Android 4.4 device . Once disabled nothing should be able to take control or activate it, even calling. I can root the device for this.
Any help would be appreciated.
As written here: How to mute audio in headset but let it play on speaker programmatically?
AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_IN_CALL);
am.setSpeakerphoneOn(false);
And then play the sound through the AudioManager.STREAM_SYSTEM stream.
When the sound's finished playing be sure to return the audio manager to its previous state or it'll stay on loudspeaker.
I am writing an App that plays media on Google TV. I want to control volume up/down from inside my App. I tried the following code and here are my test results -
Does NOT work on Google TV "box type" products (e.g. Sony NSZ-GS7) -
does not change volume of connected TV or AVR.
On Google TV "embedded in TV" type products (e.g Sony NSXGT1), it changes volume of the TV itself, did not test AVR yet on this setup
Works fine for Volume up/down on phones/tablets (e.g Nexus 4)
void volume_up(Context context){
private AudioManager audio = null;
audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
}
What API do I need to call to make #(1) scenario above to work ?
I do not want to use Anymote protocol since it requires pairing & user interaction for pairing which I do not want.