Search code examples
google-glassgoogle-gdk

Google glass GDK app handling lifecycle


I am developing an app , it has a service which renders a low frequency live card.When the app is already running, I move to OK glass and again open the app, nothing happens.I expect it to move me to left of OK glass where is live card is rendering.Is this something handled by Google glass or We should handle it explicitly?


Solution

  • You should handle this in your Service when it is restarted and navigate to the LiveCard with:

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (mLiveCard == null) {
            mLiveCard = new LiveCard(this, LIVE_CARD_TAG);
    
            // Initialize the LiveCard with its renderer and PendingIntent.
            mLiveCard.publish(PublishMode.REVEAL);
        } else {
            // Navigate to the existing LiveCard.
            mLiveCard.navigate();
        }
    
        return START_STICKY;
    }
    

    You can see how it's done in the Compass' CompassService class.