Search code examples
google-glassgoogle-gdk

How to send focus from card to home after onClick


I have an Activity that accepts voice input, instantiates a Card and then responds to an onClick event. When the onClick fires off, I want redirect the use back to the "OK Glass" view or the timeline containing a historical card representing that action. I can't seem to find any obvious way to do this...


Solution

  • In a live card, you can call:

    finish();
    

    to return to the home screen (OK Glass).

    I tested this on XE16 and it worked.

    Here is some more detailed code from my Activity:

        @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_CENTER:
            {
                    //return to OK Glass screen
                finish();
                return true;
            }
        }
        return super.onKeyDown(keyCode, event);
    }
    

    If you provide some code to make your question more specific I can provide more specific guidance.