Code example for SparseIntArray

Methods: keyAt

0
        public int getKeyCount() { 
            return mKeys.size();
        } 
 
        public int getKeyCode(int keyIndex) {
            return mKeys.keyAt(keyIndex);
        } 
 
        public boolean isKeyPressed(int keyIndex) {
            return mKeys.valueAt(keyIndex) != 0;
        } 
 
        public boolean onKeyDown(KeyEvent event) {
            final int keyCode = event.getKeyCode();
            if (isGameKey(keyCode)) {
                if (event.getRepeatCount() == 0) {
                    final String symbolicName = KeyEvent.keyCodeToString(keyCode);
                    mKeys.put(keyCode, 1);
                    Log.i(TAG, mDevice.getName() + " - Key Down: " + symbolicName);
                } 
                return true;