0

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

Johan Pelgrim
  • 6,033
  • 6
  • 37
  • 46

1 Answers1

0

I suspect that it thinks the natural orientation of the device is portrait, and does not compensate for orientation changes (which some other devices do).

When you hold the device in portrait orientation, does the lower button send volume-down?

When you rotate the device to landscape, does the same button still send volume-down, even though intuitively it should be volume-up?

I have noticed this behavior on another Acer-built 7" tablet, and reported said behavior as a bug (or at least a feature request).

Sparky
  • 8,437
  • 1
  • 29
  • 41