How to disable the physical volume buttons on Android?
<p>I am developing an Android application, and my apps will play out an alarm once it is started, but I would like to disable the external volume buttons so that when the phone is alarming, user is not able to turn down the alarm volume. I have tested on my phone with Android version 2.3.5, but it is not working. Below is my coding. Hope someone can help me... Thanks.</p>

<pre><code>@Override
public boolean onKeyDown(int keyCode, KeyEvent event){

    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP){
        Toast.makeText(this, "Volume Up", Toast.LENGTH_LONG).show();
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){
        Toast.makeText(this, "Volume Down", Toast.LENGTH_LONG).show();
        return true;
    }

    return super.onKeyDown(keyCode, event);
}
</code></pre>
