Chapter 10. Card Actions and Subscriptions

A number of people have asked recently what the big deal about wearables is. After all, they reason, they’re just new notification delivery platforms, right? If that’s all Glass was, we might agree. Let’s face it—the programs you build admittedly wouldn’t be very interesting if they couldn’t receive input from users and properly respond to it. Interactivity is where it’s at, even with wearable computing, check that—_especially_ with wearable computing—and this isn’t a facet the Glass team neglected to build into the platform. While some services will be just fine existing as static read-only mediums, you’ve got the choice of being able to easily integrate a stout feedback loop into your projects if they demand such functionality.

This chapter primes you on what you’ll need to know about using the default actions included with cards, how to create your own menu items unique to your Glassware, and how to programmatically manage subscriptions to tie it all together. We discuss how your service needs to define what actions are available within cards, how to accept those actions, and how to verify the authenticity of responses.

Simple Event Actions

We’ve already learned about a couple of menu items, and learned how to add one to an event. Let’s recap what that looked like:

{
  "text": "Hello Glass",
  "notification": {
    "level": "DEFAULT"
  },
  "speakableText": "hello there Glass",
  "menuItems": [
    { "action": "READ_ALOUD" }
  ]
}

As you may have noticed,

Get Designing and Developing for Google Glass now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.