I'm capturing the VOLUME_UP and VOLUME_DOWN keys to increase respectively decrease a value in my app. I use the following 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) {
// Do something to increase a value
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) {
// Do something to decrease a value
}
return true;
default:
return super.dispatchKeyEvent(event);
}
}
This works fine on most devices, however, one of our users reports that on the Acer Iconia 7" tablet the buttons have a reversed effect?! I.e. volume up decreases the value, where volume down increases it. The app is fixed in portrait, so no orientation changes. What might cause this effect? How can I test this without having the actual device at hand? Can I work around this in a generic (preferred) or specific way for this device?
Thanks for sharing your thoughts,
Cheers,
Johan