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
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 trying to identify how to route a very short audio stream (a notification) to a bluetooth headphone that is already paired with the device, while the device is ringing.
When I play any audio at any time, it is routed to the bluetooth device, no problem.
But if I try to start playing the audio when receiving an android.intent.action.PHONE_STATE, in RINGING state, the audio is not routed as expected.
I can see that the AudioManager's setBluetoothA2dpOn method has became deprecated, but I actually tried it but is seems has no effect.
I have tried the MediaRouter object, but I can see that MediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_AUDIO) points to the RouteInfo of the Bluetooth device while the device is ringing, and the AudioManager.isBluetoothA2dpOn is true.
So, can any one tell me why the audio route is like this in the ringing moment? is there any way to force the audio to be routed to the Bluetooth device in such case?
[UPDATED]
I have tried again today and I have discovered something that may be the cause of the problem.
I have created a BroadcaseReceiver to detect the change in the android.intent.action.PHONE_STATE. if an intent is received and the state is currently ringing, check for AudioManager's mode and you will find it is MODE_NORMAL. but few seconds later the phone will start actually ringing and the mode is going to be changed into MODE_RINGTONE. trying to manually set the mode using the method setMode(AudioManager.MODE_NORMAL) is useless then, the state remains MODE_RINGTONE even after setting it to MODE_NORMAL.
Now, I think the cause of the problem is that in the MODE_RINGTONE mode, all the streams are directed to the phone speaker and here there is no way offered by the android system to change the mode.
I think the Media player realease the bluetooth connection when the phone is ringing. You can try to obtain the bluetooth audio connection and see if Media player now play through your obtained connection. You can use my class at my answer Using the Android RecognizerIntent with a bluetooth headset and see if it works. The audio in the class is Sco only.
As stated in the JavaDoc for the StartBluetoothSco method:
Note that the phone application always has the priority on the usage of the SCO connection for telephony. If this method is called while the phone is in call it will be ignored. Similarly, if a call is received or sent while an application is using the SCO connection, the connection will be lost for the application and NOT returned automatically when the call ends.`
I tried to start sco then play a music clip in normal mode, it played to the Bluetooth headset without problems, although I couldnot stop the microphone that caused the input stream plays to the headset. I then tried to call my target phone from another phone while the music is still playing, I found that the stream has got redirected automatically to the phone speaker. After the ringing mode is finished, the stream did not get redirected again to the Bluetooth headset and I think that behavior is normal according to what is stated in the JavaDoc above.
My guessing is that Android tries to protect the ringing and in-call modes as possible in order not to allow any unwanted interference from applications. In other words, when in ringing mode then no sound is going to be played to the headset until the call is accepted, and you cannot even change the AudioManager mode from ringing to another mode, your call for mode setter will be ignored.
I have tried the AudioTrack instead of MediaPlayer, but that makes no difference.
I have then tried the TextToSpeech engine like this:
in the main activity, initialize on create:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textToSpeech=new TextToSpeech(this, this);
textToSpeech.setLanguage(Locale.US);
textToSpeech.addEarcon("[wwww]", "XXXXXXXXXXXXXXXXXXXXXXX", R.raw.a);
}
in the broadcast receiver class when rining starting the Bluetooth utility class and adding the below to the onScoAudioConnected method
textToSpeech.playEarcon("[wwww]", TextToSpeech.QUEUE_FLUSH, null);
This did not work too.
I've written a videoplayer for Android based on Flash (10.2) which plays videostreams. In some cases (*), the player begins to buffer for quite some time.
Now, while the player is acually playing the stream, Flash (somehow) signals the OS to prevent entering the sleep-mode. But while buffering, this is not the case and the phone will eventually enter sleep mode before the stream has restarted. So the user has to unlock the phone again - not very convenient.
Is there a way to set a signal with Flash/AS3 to prevent the Andoid-phone to go into sleep mode?
(*) mostly over the mobile network when the network access performes a handover between 3G and 2G or vice versa
just use
// no dimming
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
in your mxml or as file.