How to take control of the volume buttons in Android?
<p>I am developing an Android apps where user is able to find the phone once it is lost and I plan to implement the remote ringing function, I would like to do something like when the alarm is ringing, no matter the volume up or down key is pressed, the volume will still remain loudest while the alarm is ringing... But I have no idea how to achieve this... I just able to detect the event of volume keys pressed... Kindly need help for this.. 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>
