deep dive into google glass live cards


GGDevCon

Luis de la Rosa
Lead Application Developer
Capital One

   please ask questions   

glanceable ui


Fundamentally different from phone and tablet UI

Less content

Quicker

Bigger

Now

GDK vs ANDROID SDK


7 new packages

15 new classes

No emulator

Activities + Services play special roles

live cards in wear sdk?



synergy

“The API surface of GDK Glassware is not limited to the classes contained in the GDK Add-on. The GDK Add-on merely closes the gaps between the Android SDK and features that are unique to Glass. This means, in general, given a problem that isn't covered by the GDK library directly, just attempt the Android solution.”
- Jenny Tong
Staff Developer Programs Engineer on Google Glass

what is a live card?


Live cards appear in the present and future section of the timeline and display information that is relevant at the current time.


Access to GDK API (vs static cards)

Exist in Timeline (vs Immersions)

Continue to run in background

low vs high frequency


Two types of live cards:

Low frequency (every few seconds)

High frequency (real-time)

Refers to rendering speed

services + live cards


Integral

Handles lifecycle

Key to background

live card lifecycle - start

Voice Trigger

Service starts
onStartCommand() {
    if (liveCard == null) {
       liveCard = new LiveCard(context, LIVE_CARD_TAG);       liveCard.setAction(menuActivityPendingIntent);       // set up UI for LiveCard and then...
       liveCard.publish(SILENT or REVEAL);    } else {
       // See LIVE CARD LIFECYCLE - NAVIGATE slide
    }
    return START_STICKY;
}


life card lifecycle - navigate

liveCard.navigate();
Use this when your live card exists and
you want to show it again

live card lifecycle - stopping

Menu Activity
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {        case R.id.action_stop:          // Stop the Service which will also unpublish the LiveCard          stopService(new Intent(this, LiveCardService.class));          return true;	            default:          return super.onOptionsItemSelected(item);    }} 
Service stops
onDestroy() {    if (liveCard.isPublished()) { liveCard.unpublish(); } }

activity wrapper


Activity performs configuration

Activity starts Service

Timer sample

Thanks to John Fontaine

low frequency live card


Likely to be most common

Restricted to RemoteViews

Must call setViews to update

Cousin to App Widget

remoteviews


Subset of all Views

4 Layouts

7 Views

5 ViewGroups

Update only occurs when setViews is called

layouts


FrameLayout

LinearLayout

GridLayout

RelativeLayout

views


AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView

viewgroups


GridView
ListView
StackView

AdapterViewFlipper
ViewFlipper

working around lack of remote views


Example: RatingBar

Option 1: use ImageView

Option 2: switch to High-Frequency and
render onto Surface

example: stack overflow profile


Useful to see inbox and also track score

Stack Overflow rep changes relatively infrequently

Lots of data -> Glanceable

Low frequency Live Card

Menu for actions

   any questions so far?  

high-frequency live card


Live cards can update frequently with custom graphics to show users real-time information. This functionality is great for UIs that need to constantly update based on some user data.

Uses a Surface

surface


Callbacks

surfaceCreated(SurfaceHolder holder)surfaceChanged(SurfaceHolder holder)surfaceDestroyed(SurfaceHolder holder) 

Use background Thread

Custom drawing

Rendering of common Views

example: audio visualizer


Uses microphone

Samples audio

FFT

Draws waveform on Surface

menu


PendingIntent as Action

Activity hosts menu items

Register the Activity

onAttachedToWindow

Transparency via style

Must have at least Stop menu item

menu activity

    public class MenuActivity extends Activity {

        @Override
        public void onAttachedToWindow() {
            super.onAttachedToWindow();
            openOptionsMenu();
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.stopwatch, menu);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle item selection.
            switch (item.getItemId()) {
                case R.id.stop:
                    stopService(new Intent(this, StopwatchService.class));
                    return true;
                default:
                    return super.onOptionsItemSelected(item);
            }
        }

        @Override
        public void onOptionsMenuClosed(Menu menu) {
            // Nothing else to do, closing the activity.
            finish();
        }
    } 

voice menus

LiveCard:
liveCard.setVoiceActionEnabled(true); 
Menu Activity:
boolean fromLiveCardVoice = getIntent().getBooleanExtra(LiveCard.EXTRA_FROM_LIVECARD_VOICE, false);
if (fromLiveCardVoice) {
 // When activated by voice from a live card, enable voice commands. The menu
 // will automatically "jump" ahead to the items (skipping the guard phrase
 // that was already said at the live card).
 getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS);
}
 

timeline


Publishing: Silent or Reveal

Navigate

Pair Silent with boot up Services

Overrides some gestures

gdk samples


High-Frequency Live Cards

Use the layout rendered to Surface trick

Sensors

Service - Drawer/Renderer - View pattern

dissecting the gdk samples


Compass

Stopwatch

Timer

vs immersions


Can't control dimming

Can't have a bundle of cards

Starts back up after wake

Not as much control over touch / gestures

gotchas


Menu Activity required to publish
- not declaring in AndroidManifest.xml
- transparent theme
- onAttachedToWindow

setViews to refresh

setString vs setCharSequence

No callback when low frequency Live Card viewed

Tips


Auto-start after reboot

Jump to existing Live Card

Use Surface callbacks

NEXT Steps


https://developers.google.com/glass/community

Tag [google-gdk] on Stack Overflow

File Bugs / Feature requests

Join local Glass meetups

Please give feedback via the app or via paper

   slides and code are available via   

   luisdelarosa.com/glass 

Deep Dive into Google Glass Live Cards 2.0

By Luis de la Rosa

Deep Dive into Google Glass Live Cards 2.0

Presented at GGDevCon

  • 878
Loading comments...

More from Luis de la Rosa