My app does requestAudioFocus(STREAM_VOICE_CALL) and then calls
AudioManager#setMode(MODE_IN_COMMUNICATION). The log shows that this
immediately causes the audio focus to be lost to
AudioService.IN_VOICE_COMM_FOCUS_ID
("AudioFocus_For_Phone_Ring_And_Calls"):

I/AudioService(23967):  AudioFocus  requestAudioFocus() from
android.media.audiomana...@41a56f58com.shri.MyApp@41b1c450
E/audio_hw_primary(  117): Leaving IN_CALL state, in_call=0, mode=3
I/AudioService(23967):  AudioFocus  requestAudioFocus() from
AudioFocus_For_Phone_Ring_And_Calls

There is no such loss in audio focus on Gingerbread. Also, if I do
AudioManager#setMode(MODE_NORMAL), there is no loss in audio focus,
but I have other issues (volume is low because the GIPS audio library
does not route audio correctly).

Looking at AudioService.java (http://www.java2s.com/Open-Source/
Android/android-core/platform-frameworks-base/android/media/
AudioService.java.htm), I see that AudioService.IN_VOICE_COMM_FOCUS_ID
grabs focus when there is an incoming phone call using
PhoneStateListener. I registered my own PhoneStateListener, but it did
not get called when I called
AudioManager#setMode(MODE_IN_COMMUNICATION).

Can I use AudioManager#setMode(MODE_IN_COMMUNICATION) while keeping
audio focus?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to