0

So I'm publishing a Live Card on Google Glass using the GDK, but I can't work out a way to unpublish the card after I publish a new one. If I don't it goes back to the clock screen and looks bad.

Here's my liveCard Publishing, can you select an already active card and delete it later? I expect this is a logic problem but I can't quite get my head around it.

public void makeNotificationCard() {
    RemoteViews aRV = new RemoteViews(this.getPackageName(), R.layout.card_text);
    mNotCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
    aRV.setTextViewText(R.id.price, bigNum);
    aRV.setTextViewText(R.id.price2, littleNum);
    aRV.setTextViewText(R.id.merchant, shop);
    mNotCard.setViews(aRV);
    Intent mIntent = new Intent(this, MainActivity.class);
    mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    mNotCard.setAction(PendingIntent.getActivity(this, 0, mIntent, 0));
    mNotCard.publish(LiveCard.PublishMode.REVEAL);
}
DaveOrrock
  • 63
  • 1
  • 1
  • 8

1 Answers1

0

Firstly, as of XE16 the TimelineManager has been removed. So instead of:

mNotCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);

You will need to use

mNotCard = new LiveCard(context, LIVE_CARD_ID);

As for unpublishing, I'm not entirely sure I've understood your issue, but you can simply call

mNotCard.unpublish();

and this will remove the card from the timeline. If you do this before creating a new LiveCard and you publish the new one with LiveCard.PublishMode.REVEAL it should jump straight to that, I use something like

public int onStartCommand(Intent intent, int flags, int startId) {
    if (mLiveCard != null) {
        mLiveCard.unpublish();
        mLiveCard.publish(LiveCard.PublishMode.REVEAL);
        return START_STICKY;
    }
    // other stuff to set up card if null
}

and this will ensure that when the command if fired it will take focus to the livecard.

Hope that helps. If I've missed the point let me know and I'll try and clarify.

Ben
  • 1,767
  • 16
  • 32
  • I've tried something similar but I found that when I used `mLiveCard.publish(LiveCard.PublishMode.REVEAL);` after `mLiveCard.unpublish();` There was a slight delay between them which focuses the application on the main menu instead of my app. I'm currently usin XE12 I think I haven't performed the latest update as it may effect some presentation pieces in the next week or so. – DaveOrrock May 08 '14 at 12:11
  • Yeah, XE16 broke a few of my demos. And I think you may find the issue you have is actually made worse with XE16/17 as now when you do Reveal it zooms out of the timeline ans shows the card being inserted, which is nice for providing context but not great if you want it to be seamless. I guess the question is when do you need to unpublish/republish, can you just change the contents of the displayed card? – Ben May 08 '14 at 15:19