Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android workshop - 02. Glass development 101

Android workshop - 02. Glass development 101

Johnny Sung

January 21, 2015
Tweet

More Decks by Johnny Sung

Other Decks in Technology

Transcript

  1. VoiceTriggers.Command • add an event • calculate • call me

    a car • capture a panorama • check me in • check this out • control my car • control my home • explore nearby • explore the stars • find a bike • find a dentist • find a doctor • find a hospital • find a passage • find a place • find a place to stay • find a product • find a recipe • find a video • find a website • find reviews • find the exchange rate • find the price • flip a coin • give me feedback • help me sign in • keep me awake • learn an instrument • learn a song https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/app/VoiceTriggers.Command
  2. AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.johnny.petstarglass" > <application android:allowBackup="true"

    android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <!-- ... --> </application> </manifest> Remove android:theme
  3. Do some changes 2. Edit files • Change ActionBarActivity to

    Activity
 (MainActivity.java) • Remove android:theme
 (AndroidManifest.xml) • Remove unused padding’s var
 (activity_main.xml)
  4. AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.johnny.petstarglass" > <application android:allowBackup="true"

    android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <!-- ... --> </application> </manifest> Remove android:theme
  5. package com.johnny.petstarglass; import android.app.Activity; import android.os.Bundle; public class MainActivity extends

    Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.card_main); } } MainActivity.java Copy from android app’s Change this
  6. <?xml version="1.0" encoding="utf-8"?> <trigger keyword="My Command" /> <?xml version="1.0" encoding="utf-8"?>

    <trigger command="SHOW_ME_A_DEMO" /> Using unlisted main voice commands Edit https://developers.google.com/glass/develop/gdk/voice#unlisted_commands voice_trigger.xml
  7. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.johnny.petstarglass" > <uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />

    <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name"> <!-- ... --> </application> </manifest> AndroidManifest.xml Add this
  8. View view1 = new CardBuilder(context, CardBuilder.Layout.TEXT) .setText("This is the TEXT

    layout. The text size will adjust dynamically.") .setFootnote("This is the footnote") .setTimestamp("just now") .getView(); CardBuilder
  9. View view2 = new CardBuilder(context, CardBuilder.Layout.COLUMNS) .setText("You can even put

    a centered icon on a COLUMNS card instead of a mosaic.") .setFootnote("This is the footnote") .setTimestamp("just now") .setIcon(R.drawable.ic_wifi) .getView(); CardBuilder
  10. public class MainActivity extends Activity { @Override protected void onCreate(Bundle

    savedInstanceState) { super.onCreate(savedInstanceState); View view1 = new CardBuilder(this, CardBuilder.Layout.TEXT) .setText("This is the TEXT layout.") .setFootnote("footnote") .setTimestamp("just now") .getView(); setContentView(view1); } } MainActivity.java
  11. Touch input Swipe down translates to KEYCODE_BACK. A camera button

    press
 translates to KEYCODE_CAMERA. Tap translates to KEYCODE_DPAD_CENTER.
  12. Touch input @Override public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_CAMERA) { // ... return true; } return false; } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_CAMERA) { // ... return true; } return false; } MainActivity.java
  13. Where To Go From Here? • Check the development guide


    https://developers.google.com/glass/develop/gdk/index • Touch Gestures • Card Scroller • Slider • Live Cards