title: android equalizer not working
body: <p>I am following <a href="https://www.101apps.co.za/articles/perfect-sound-using-the-equalizer-effect-a-tutorial.html" rel="nofollow noreferrer">this </a> tutorial every thing is working fine except that the seek bar and spinner is not getting created . 
  this is what i am trying 
  java:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private MediaPlayer mediaPlayer;
  private Equalizer equalizer;
  private LinearLayout linearLayout;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      setVolumeControlStream(AudioManager.STREAM_MUSIC);
      mediaPlayer = MediaPlayer.create(this, R.raw.song);
      mediaPlayer.start();
      equalizer = new Equalizer(0, mediaPlayer.getAudioSessionId());
      equalizer.setEnabled(true);
      setUpEqualizer();
  
      mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
          @Override
          public void onCompletion(MediaPlayer mediaPlayer) {
  
          }
      });
  }
  
  public void setUpEqualizer() {
      linearLayout = (LinearLayout) findViewById(R.id.linearlayequ);
      TextView equheading = new TextView(this);
      equheading.setText("Equalizer");
      equheading.setTextSize(20);
      equheading.setGravity(Gravity.CENTER_HORIZONTAL);
      linearLayout.addView(equheading);
      short nofrequencyband = equalizer.getNumberOfBands();
      final short lowerfrequencyband = equalizer.getBandLevelRange()[0];
      final short upperfrequencyband = equalizer.getBandLevelRange()[1];
      for (short i = 0; i &lt; nofrequencyband; i++) {
          final short eqbandindex = i;
          TextView frheadertv = new TextView(this);
          frheadertv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
          frheadertv.setGravity(Gravity.CENTER_HORIZONTAL);
  
          frheadertv.setText((equalizer.getCenterFreq(eqbandindex) / 1000) + "Hz");
          linearLayout.addView(frheadertv);
          LinearLayout seeklay = new LinearLayout(this);
          seeklay.setOrientation(LinearLayout.HORIZONTAL);
  
          TextView lowereqbandlvl = new TextView(this);
          lowereqbandlvl.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
          lowereqbandlvl.setText((lowerfrequencyband / 100) + "dB");
  
          TextView highreqbandlvl = new TextView(this);
          highreqbandlvl.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
          highreqbandlvl.setText((upperfrequencyband / 100) + "dB");
  
          LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
          layoutParams.weight = 1;
          SeekBar seekBar = new SeekBar(this);
          seekBar.setId(i);
          seekBar.setLayoutParams(layoutParams);
          seekBar.setMax(upperfrequencyband - lowerfrequencyband);
          seekBar.setProgress(equalizer.getBandLevel(eqbandindex));
          seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
              @Override
              public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                  equalizer.setBandLevel(eqbandindex, (short) (i + lowerfrequencyband));
              }
  
              @Override
              public void onStartTrackingTouch(SeekBar seekBar) {
  
              }
  
              @Override
              public void onStopTrackingTouch(SeekBar seekBar) {
  
              }
          });
          seeklay.addView(lowereqbandlvl);
          seeklay.addView(seekBar);
          seeklay.addView(highreqbandlvl);
          linearLayout.addView(seeklay);
          equalizSound();
      }
  }
  
  public void equalizSound() {
      ArrayList&lt;String&gt; equalizername = new ArrayList&lt;String&gt;();
      ArrayAdapter&lt;String&gt; spinnerAdapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_spinner_dropdown_item);
      spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      Spinner spinner = (Spinner)findViewById(R.id.spinner);
      for (short i=0;i&lt;equalizer.getNumberOfPresets();i++){
          equalizername.add(equalizer.getPresetName(i));
      }
      spinner.setAdapter(spinnerAdapter);
      spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
  
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; adapterView) {
  
          }
      });
  }
  
  @Override
  protected void onPause() {
      super.onPause();
      if (isFinishing() &amp;&amp; mediaPlayer != null) {
  
          equalizer.release();
          mediaPlayer.release();
          mediaPlayer = null;
      }
  }
  }
  </code></pre>
  
  <p>Is there any permissions required to use the equalizer or where I am making mistake any advice will be helpful.The app is not throwing any exception and only the song is getting played.</p>