Search code examples
androidandroid-launcherandroid-keypadandroid-tvnexus-player

Android Launcher with KEYCODE_VOICE_ASSIST key capture


I was wondering if that would be possible with a custom launcher as it seems per the Android docs that key code is not delivered to applications.

So when pressing the mic button on remote controls or keyboards that have it, how would an app or a custom launcher react like Google's Now Launcher that opens up the voice search command for instance (not that this is the action I would like triggered but just listen to the event of pressing the button and reacting accordingly).


Solution

  • You can override onSearchRequested() in your Activity:

    @Override
    public boolean onSearchRequested() {
        // return false if you just want to listen to the event
        // return true if you are overriding the system's functionality
    
    }