Overriding Hardware Volume keys

All your problems with Audio, Video and Images.

Overriding Hardware Volume keys

Postby OrdeS » Sat Feb 14, 2009 6:35 am

I want to override the volume keys so that instead of controlling the ringer volume or media volume depending on the fact if there is sound playing at the moment or not, to control an internal application volume, regardgless of system volume.
This is what I'm doing:

public boolean onKeyUp(int keyCode, KeyEvent msg) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP){
adjustVolume(+1);
return true;
}
}
It is my understanding that if I do return true, the event should be killed thus preventing further propagation to the system default behavior. But this is not the case for some reason.
Is my logic flawed or ?
OrdeS
Freshman
Freshman
 
Posts: 3
Joined: Sat Feb 14, 2009 6:30 am

Top

Postby MrSnowflake » Sun Feb 15, 2009 9:18 am

The volume is probably changed as long as the volume key is down, so you should also intercept the onKeyDown() event for the Voume key.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 12 guests