title: set Audio Attributes in SoundPool.Builder class for API 21
body: <p>I am following an Android Programming video lecture series which was designed in the pre-API 21 times. Hence it tells me to create a SoundPool variable in the following manner.</p>
  
  <pre><code>SoundPool sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
  //SoundPool(int maxStreams, int streamType, int srcQuality)
  </code></pre>
  
  <p>However, I want to use this SoundPool for API 21 as well. So, I am doing this:</p>
  
  <pre><code>if((android.os.Build.VERSION.SDK_INT) == 21){
      sp21 = new SoundPool.Builder();
      sp21.setMaxStreams(5);
      sp = sp21.build();
  }
  else{
      sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
  }
  </code></pre>
  
  <p>sp21 is a variable of <code>Builder</code> type for API 21 and sp is of <code>SoundPool</code> type.</p>
  
  <p>This works very well with my AVD having API 21 and real device having API 19. (Haven't tried with a real device with API 21 but I think it will work well). Now, I want to set the <code>streamType</code> to <code>USAGE_MEDIA</code> in the if-block before <code>sp = sp21.build();</code>. So I type:</p>
  
  <pre><code>sp21.setAudioAttributes(AudioAttributes.USAGE_MEDIA);
  </code></pre>
  
  <p>But the Lint marks it in red and says: </p>
  
  <blockquote>
    <p>The method setAudioAttributes(AudioAttributes) in the type
    SoundPool.Builder is not applicable for the arguments (int)</p>
  </blockquote>
  
  <p>I know that even if I do not set it to USAGE_MEDIA it will be set to the same by default. But I am asking for future reference if I have to set it to something else like : USAGE_ALARM.</p>
  
  <p>How should I proceed ?</p>
  
  <p>Please Help!</p>
  
  <p>I have referred to <a href="https://source.android.com/devices/audio/attributes.html" rel="noreferrer">Audio Attributes</a>, <a href="http://developer.android.com/reference/android/media/SoundPool.html" rel="noreferrer">SoundPool</a>, <a href="https://developer.android.com/reference/android/media/SoundPool.Builder.html" rel="noreferrer">SoundPool.builder</a> and <a href="http://developer.android.com/reference/android/media/AudioManager.html" rel="noreferrer">AudioManager</a>.</p>