How do I send bundled cards all at the same time?
Asked Answered
S

1

7

I've set up a Java application where I'm creating a bundle of 4 cards. The problem is that all the cards do not come in at once. Some times just one shows up, then a few seconds or minute later the other cards show up. How do I get them to all show up on the headset at the same time?

edit: I tried HTML paging and that didn't work and now I think I'm more confused. So in my senario here I want to send a bunch of landmarks to the user that they can navigate to. I want all the landmarks in a bundle, I want a cover to the bundle that isn't an option in the bundle saying "here are your landmarks", and I'd like the bundle to get to the user all at the same time. How can I achieve this?

TimelineItem timelineItemEmpire = new TimelineItem();
timelineItemEmpire.setText("Empire State Building");

// Triggers an audible tone when the timeline item is received
timelineItemEmpire.setNotification(new NotificationConfig().setLevel("DEFAULT"));
Location empireLoc = new Location();
empireLoc.setLatitude(40.748492);
empireLoc.setLongitude(-73.985868);
timelineItemEmpire.setLocation(empireLoc);

// Attach an image, if we have one
URL url = new URL(WebUtil.buildUrl(req, "/static/images/empirestate.jpg"));
timelineItemEmpire.setBundleId(bundleId);

List<MenuItem> menuItemList = new ArrayList<MenuItem>();
menuItemList.add(new MenuItem().setAction("NAVIGATE"));
timelineItemEmpire.setMenuItems(menuItemList);

MirrorClient.insertTimelineItem(credential, timelineItemEmpire, contentType, url.openStream());

TimelineItem timelineItemCP = new TimelineItem();
timelineItemCP.setText("Central Park");

// Triggers an audible tone when the timeline item is received
timelineItemCP.setNotification(new NotificationConfig().setLevel("DEFAULT"));

// Attach an image, if we have one
URL url3 = new URL(WebUtil.buildUrl(req, "/static/images/central_park.jpg"));
timelineItemCP.setBundleId(bundleId);

Location cpLoc = new Location();
cpLoc.setLatitude(40.772263);
cpLoc.setLongitude(-73.974488);
timelineItemCP.setLocation(cpLoc);
timelineItemCP.setMenuItems(menuItemList);

MirrorClient.insertTimelineItem(credential, timelineItemCP, contentType, url3.openStream());      

TimelineItem timelineCover = new TimelineItem();
timelineCover.setText("Nearby Landmarks");
timelineCover.setBundleId(bundleId);

// Triggers an audible tone when the timeline item is received
timelineCover.setNotification(new NotificationConfig().setLevel("DEFAULT"));

// Attach an image, if we have one
URL url4 = new URL(WebUtil.buildUrl(req, "/static/images/bundle_cover.jpg"));

MirrorClient.insertTimelineItem(credential, timelineCover, contentType, url4.openStream());  
Somewhere answered 22/5, 2013 at 18:41 Comment(2)
Actually it looks like HTML paging is what I need. Trying that now.Somewhere
OK look like paging doesn't work for me either.Somewhere
M
6

You need to set the isBundleCover resource to true for your cover; i.e.:

timelineCover.setIsBundleCover(true);

This will make it the entry point into the bundle, and prevent it from being displayed within the bundle, as described here.

Furthermore, you can use BatchRequest to make sure they're sent together; e.g.,:

BatchRequest batch = MirrorClient.getMirror(null).batch();
BatchCallback callback = new BatchCallback();

for (TimelineItem item : items) {
        MirrorClient.getMirror(userCredential).timeline().insert(item).queue(batch, callback);
}

batch.execute();
Mariettamariette answered 22/5, 2013 at 20:11 Comment(2)
Thanks a lot! This worked great. Did you get this from some documentation that I missed online? If so can you point me to it.Somewhere
Cool - I saw the setIsBundleCover method browsing the docs mentioned in my answer above, and the BatchRequest class reading through the Google quickstart project.Mariettamariette

© 2022 - 2024 — McMap. All rights reserved.