What I'm trying to do is to make call from my app and turn on speaker in this call.
Everything was okay on android 4.0, I've just set audiomanager.setSpeakerphoneOn(true) before starting call intent.
But on android 4.1 PhoneUtils checkin speaker state before call and turn it off(logcat):
D/PhoneUtils( 1029): about to activate speaker
D/PhoneUtils( 1029): activateSpeakerIfDocked()...
I/PhoneUtils( 1029): Forcing speaker off when initiating a new outgoing call...
I've also tried to listen call state using : mTelephonyManager.listen(receiver, PhoneStateListener.LISTEN_CALL_STATE); After this receiver will catch 3 states:
But last "event" was also send before PhoneUtils check speaker state(logcat):
11:43:48.089 D/KeyguardViewMediator( 665): keyguard receiver action : android.intent.action.PHONE_STATE
11:43:48.089 D/KeyguardViewMediator( 665): keyguard receiver TelephonyManager.EXTRA_STATE : OFFHOOK
11:43:48.099 D/PhoneUtils( 977): setAudioMode()...OFFHOOK
11:43:48.099 D/MyPhoneStateListener:main( 2590): catching call state CALL_STATE_OFFHOOK
11:43:48.099 D/MyPhoneStateListener:main( 2590): turning phone speaker on
...
11:43:48.119 D/PhoneUtils( 977): about to activate speaker
11:43:48.119 I/PhoneUtils( 977): Forcing speaker off when initiating a new outgoing call...
If somebody faced with same problem or have a solutuion?
Thanks!
I've had this problem this week..
Reading the jelly bean code source, i've found this code
// This is not an error but might cause users' confusion. Add log just in case.
Log.i(LOG_TAG, "Forcing speaker off when initiating a new outgoing call...");
PhoneUtils.turnOnSpeaker(app, false, true);
So that's it, in version 4.1 android forces speaker off in incoming and outgoing calls. My solution is turn on the speaker in my call state broadcast receiver, after start to make a call