title: Android How to listen for Volume Button events?
body: <p>I know you guys are probably tired of these kinds of posts, but why doesn't anything happen when I press volume down? I'm just trying to make a simple code, but apparently it's not working.</p>
  
  <pre><code>package com.cakemansapps.lightwriter;
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.View.OnTouchListener;
  import android.widget.FrameLayout;
  import android.view.KeyEvent;
  import android.util.Log;
  
  public class LightWriter extends Activity implements OnTouchListener {
  private static final String TAG = "Touch" ;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    FrameLayout main = (FrameLayout) findViewById(R.id.main_view);
  }
  
  @Override
  public boolean onKeyLongPress(int keyCode, KeyEvent event) {
  if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) 
  {
      Log.w("LightWriter", "I WORK BRO.");
      return true;
  }
  return super.onKeyLongPress(keyCode, event);
  }
  
  public boolean onTouch(View view, MotionEvent me) {
      throw new UnsupportedOperationException("Not supported yet.");
  }
  
  }
  </code></pre>