我该如何同时发送打包的卡片?

7
我已经设置了一个Java应用程序,其中我正在创建一个由4个卡片组成的捆绑包。问题是,并非所有的卡片都会立即显示出来。有时只有一张牌显示出来,然后几秒钟或几分钟后其他牌才显示出来。如何让它们同时显示在耳机上?
编辑: 我尝试了HTML分页,但那并没有起作用,现在我更加困惑了。所以在我的情境中,我想向用户发送一堆他们可以导航到的地标。我希望所有地标都在一个捆绑包中,我想要一个不在包中的封面,上面写着“这里是你的地标”,而且我希望捆绑包能够同时到达用户手中。我该如何实现这一点?
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());  

实际上,看起来我需要HTML分页。现在正在尝试。 - Pickles
好的,看起来分页对我也不起作用。 - Pickles
1个回答

6
你需要将资源中的isBundleCover设置为true,以便为你的封面进行设置。例如:
timelineCover.setIsBundleCover(true);

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

此外,您可以使用BatchRequest来确保它们一起发送;例如:

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

非常感谢!这个很好用。你是从我在网上错过的文档中得到的吗?如果是,能否指点一下我。 - Pickles
很棒!我在浏览上面我的答案提到的文档时发现了"setIsBundleCover"方法,并且在阅读Google快速入门项目中的BatchRequest类时也看到了它。 - MikeV

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接