如何同时发送捆绑的卡?

时间:2013-05-22 18:41:30

标签: java google-mirror-api google-glass

我已经设置了一个Java应用程序,我正在创建一组4张卡片。问题是所有卡片都不会立刻进入。有时候只有一个出现,然后几秒钟或几分钟后出现其他卡片。如何让它们同时显示在耳机上?

编辑: 我尝试了HTML分页,但是没有用,现在我觉得我更困惑了。所以在我的senario中,我想向用户发送一堆他们可以导航到的地标。我希望捆绑中的所有地标,我想要捆绑的封面不是捆绑中的选项,说“这里是你的地标”,我希望捆绑包同时到达用户。我怎样才能做到这一点?

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());  

1 个答案:

答案 0 :(得分:6)

您需要将isBundleCover资源设置为true作为封面;即:

timelineCover.setIsBundleCover(true);

这将使其成为捆绑包的入口点,并阻止它在捆绑包中显示,如here所述。

此外,您可以使用BatchRequest确保它们一起发送; 。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();