【问题标题】:How do I send bundled cards all at the same time?如何同时发送捆绑的卡片?
【发布时间】:2013-05-22 18:41:29
【问题描述】:

我已经设置了一个 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 分页。现在试试。
  • 好吧,看来分页也不适合我。

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


【解决方案1】:

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

timelineCover.setIsBundleCover(true);

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

此外,您可以使用 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();

【讨论】:

  • 非常感谢!这很好用。你是从我在网上错过的一些文档中得到的吗?如果是的话,你能指点我吗。
  • 酷 - 我看到 setIsBundleCover 方法浏览了我上面回答中提到的文档,并且 BatchRequest 类通过 Google 快速启动项目阅读。
猜你喜欢
  • 1970-01-01
  • 2011-05-14
  • 2017-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-25
  • 1970-01-01
相关资源
最近更新 更多