how to create a service, that would be listening to the volume button?
<p>I need to create a service that would be running in the background, displaying an icon in the notification bar, listen to the volume buttons being presses and prevent them from changing the volume, so that annoying beep won't be heard.</p>

<p>What do you think, is that possible? And if yes, where should I start?</p>

<p>Thanks!</p>

<p>edit:</p>

<p>found this snippet that works great for an activity, now will have to try it with a service.</p>

<pre><code>@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();
        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (action == KeyEvent.ACTION_UP) {
                Toast.makeText(this, "UP", 1500).show();
            }
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (action == KeyEvent.ACTION_DOWN) {
                Toast.makeText(this, "DOWN", 1500).show();
            }
            return true;
        default:
            return super.dispatchKeyEvent(event);
        }
    }
</code></pre>

<p>edit2:
found a nice tutorial over here <a href="http://android.kgmoney.net/2010/05/08/creating-a-simple-android-service-for-background-processing/" rel="nofollow">http://android.kgmoney.net/2010/05/08/creating-a-simple-android-service-for-background-processing/</a></p>

<p>created a service, but the above code doesn't seem to fit into it... hmm...</p>
