You would just define it for the activity where using the volume is a problem... All it does is intercept those hardware button presses and eat them, instead of passing them to the super.onKeyDown...
Of course, ideally you'd want to figure out why pressing the volume buttons is bad...
Well, the code snippet intercepts all the hardware button presses... If you only want to disable during playback, and that you're not using a dedicated activity for that, then you could add an extra flag (like "boolean playing = true;", and use it in the if condition). If your application isn't too long, it might be easier to just post the code...
The code you gave me, I placed it in my activity and when I press the volume, it still crashes the program, but where could you call that method (onKeyDown)?
The method is pasted under the onCreate, but where do you call it to activate it???
You don't need to call it anywhere, it's done automatically for you... You could add some debug printing in there to convince yourself... Too bad that didn't seem to help.