Code example for KeyEvent

0
            return; 
        } 
 
        final long now = SystemClock.uptimeMillis();
        sendMediaKey(new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keycode, 0, 0,
                KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD));
        sendMediaKey(new KeyEvent(now, now, KeyEvent.ACTION_UP, keycode, 0, 0,
                KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD));
    } 
 
    class RemoteDisplayMonitor extends IRemoteControlDisplay.Stub { 
        RemoteDisplayMonitor() { 
        } 
 
 
        @Override 
        public void setCurrentClientId(int clientGeneration, PendingIntent clientMediaIntent,
                boolean clearing) {
            System.out.println("New client: id=" + clientGeneration
                    + " intent=" + clientMediaIntent + " clearing=" + clearing);
        }