title: Connecting Hardware device buttons to SeekBar
body: <p>How do I connect Hardware device buttons with Seek bar used for volume?
  So every time I click on hardware buttons for example to increase volume, Seek Bar increase as well and vice verse</p>
  
  <pre><code>public void initControls()
  {
      try
      {
          volumeSeekbar = (SeekBar)findViewById(R.id.seekBar1);
          audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
          volumeSeekbar.setMax(audioManager
                  .getStreamMaxVolume(AudioManager.STREAM_MUSIC));
          volumeSeekbar.setProgress(audioManager
                  .getStreamVolume(AudioManager.STREAM_MUSIC));   
  
  
          volumeSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() 
          {
              @Override
              public void onStopTrackingTouch(SeekBar arg0) 
              {
              }
  
              @Override
              public void onStartTrackingTouch(SeekBar arg0) 
              {
              }
  
              @Override
              public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) 
              {
                  audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
                          progress, 0);
              }
  
          });
  
      }
      catch (Exception e) 
      {
          e.printStackTrace();
      }
  
  }
  @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) 
       { 
              int index = seekbar1.getProgress(); 
              seekbar1.setProgress(index + 1); 
              return true; 
       } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
        {
              int index = seekbar1.getProgress(); 
              seekbar1.setProgress(index - 1); 
              return true; 
       }
        return super.onKeyDown(keyCode, event); 
       }
  </code></pre>
  
  <p>Here is the edited code, I get error  The method onKeyDown (int, keyEvent)is undefined for the type object. </p>