title: How do you disable "ducking" in Android?
body: <p>I have an Android game that plays some sound effects when users interact with it. Some of my users are complaining that while they are playing audio books or music my app will lower the volume of the background music or book. The app uses SoundPool to play in game sound effects. However the issue exists even when sound if off. In a test version of the app I even skipped the initialization of SoundPool and it had no effect. I'm not sure even where to look for this issue. I have read this article but it was no real help. <a href="https://developer.android.com/training/managing-audio/audio-focus.html" rel="nofollow">https://developer.android.com/training/managing-audio/audio-focus.html</a></p>
  
  <p>How do I make my app surrender all rights to sound and allow background apps to play at full volume?</p>
  
  <pre><code>// Create java sound pool
      // Check if we're running on Android 5.0 or higher
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {
          //Load soundpool
          AudioAttributes attrs = new AudioAttributes.Builder()
                  .setUsage(AudioAttributes.USAGE_GAME)
                  .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                  .build();
          javaSoundPool = new SoundPool.Builder()
                  .setMaxStreams(10)
                  .setAudioAttributes(attrs)
                  .build();
      } else {
          //Load pre lollipop sound pool
          javaSoundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
      }
  
  private void playJavaSoundPool(final SoundData soundData) {
      final int soundPoolId;
      //Random find the real map
      if(soundData.soundId == RANDOM_WINNER){
          final int mapId = randomWinnerSound();
          soundPoolId = soundMap.get(mapId).soundPoolId;
      } else {
          soundPoolId = soundData.soundPoolId;
      }
      // Set volume
      float streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
      streamVolume = streamVolume / audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
      // Play sound
      javaSoundPool.play(soundPoolId, streamVolume, streamVolume, 1, 0, 1.0f);
  }
  </code></pre>