Code example for KeyEvent

Methods: isCanceledisTracking

        return super.onKeyDown(keyCode, event);
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
                && !event.isCanceled()) {
            if (getScale() > 1.0f) { 
                // If we're zoomed in, pressing Back jumps out to show the 
                // entire image, otherwise Back returns the user to the gallery. 
                return true; 
        return super.onKeyUp(keyCode, event);
    protected Handler mHandler = new Handler();
Experience pair programming with AI  Get Codota for Java