title: Set the volume control stream from a service on Android
body: <p>I'm working on a music app which consists in a Service playing music while other apps are running.</p>
  
  <p>In order to enjoy the music and only the music, the Service mutes all the other apps. In order to do that, it mutes STREAM_MUSIC and play music over STREAM_VOICE_CALL (found that solution to mute other apps <a href="https://stackoverflow.com/questions/1993471/android-can-i-mute-currently-playing-audio-applications">here</a>)</p>
  
  <p>As the Service uses STREAM_VOICE_CALL to play music, what I'm trying to find is a way to make the volume buttons control this stream when a sound is playing.</p>
  
  <p>What I already tried:</p>
  
  <ul>
  <li><a href="http://developer.android.com/reference/android/app/Activity.html#setVolumeControlStream(int)" rel="nofollow noreferrer">setVolumeControlStream</a>: only works in Activities</li>
  <li>Capturing volume keys pressed events: Services do not receive such events (<a href="https://stackoverflow.com/a/11397294/1532392">source</a>)</li>
  <li>audioManager.setMode(AudioManager.MODE_IN_CALL) : does not work in my case. Plus, the <a href="http://developer.android.com/reference/android/media/AudioManager.html#setMode%28int%29" rel="nofollow noreferrer">SDK documentation</a> states that this "mode should only be used by the telephony application when it places a phone call".</li>
  </ul>
  
  <p>At this point, I'm out of options and any help would be appreciated. Thanks!</p>