1

In my application, when I start my audio call/audio broadcast I have request the audio manager for audio focus.

audioManager.requestAudioFocus(null,audioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT| AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);

If the user presses Home and navigates to another media application, and then if they play any media, that file is also played at low volume. The person receiving the call can also hear that media sound file.

When my audio call is in progress, if the user tries to play any audio resources, how do I tell the audio manager to give the preference to my application only?

Finder
  • 1,217
  • 5
  • 18
  • 46

1 Answers1

6

What you're describing is the default behavior on Android (I believe). That being said, you should be able to do what you're hoping. The Android SDK allows you to set a single stream type as solo - causing all other streams to be muted. To do this, you should use the AudioManager setStreamSolo()call:

audioManager.setStreamSolo(AudioManager.STREAM_VOICE_CALL, true);

You'll want to do this when playback begins, then set the stream solo to false when playback ends or your Activity finishes. Let me know if that does the trick.

Couple of resources that might be helpful:

Community
  • 1
  • 1
Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
  • To make sure I understand correctly, you want to mute audio from all services except a real incoming phone call? Is that right? I think I'm confused by your wording when you say "my audio call". Does your app make some kind of voice calls? Are you wanting to pause that call if an actual phone call came in? – Kyle Clegg Jul 16 '12 at 17:11