Introduction to google glass

69
PRESENTING GOOGLE GLASS

description

Google Glass

Transcript of Introduction to google glass

Page 1: Introduction to google glass

PRESENTING GOOGLE GLASSPRESENTING

GOOGLE GLASS

Page 2: Introduction to google glass

For this presentation, and source code used, visit:

http://bit.ly/1qZDBhUFor this presentation, and source code used, visit:

http://bit.ly/1qZDBhU

Page 3: Introduction to google glass

Glass Components

Page 4: Introduction to google glass

Glass Experience

Page 5: Introduction to google glass

How to operateOn startup

Swipe right

Swipe left

Settings and life cards

Static cards and time-line

Say“ok glass”

Voice commands

Tap

Installed apps

Page 6: Introduction to google glass

Software Stack

AndroidSubsystem

GlassSubsystem

Glassware

Page 7: Introduction to google glass

Quick look at Android Development

Quick look at Android Development

Page 8: Introduction to google glass

Android DevelopmentPrerequisite

– JDK 6 (or newer) installed● http://bit.ly/1iOZIrD

– ADT Bundle– Android 4.4.2 (API 19) for Google Glass (with Glass Development Kit Preview)

● Download: ADT Bundle (eclipse)● http://bit.ly/1gAwCcl

Page 9: Introduction to google glass

Eclipse IDEStart eclipse

– <path-adt-bundle>/eclipse/eclipse● Perspectives

– Window > Open Perspectives > Other...● Java● Debug● DDMS

– Devices (connected), File Explorer, LogCat● Window > ADT Manager

– Android 4.4.2 (API 19) for Google Glass (with Glass Development Kit Preview)

● Window > Android Virtual Device Manager

– No simulator for Google Glass (must use real device)

Page 10: Introduction to google glass

Platform Tools

<path-adt-bundle>/sdk/platform-tools/adb

● adb install application.apk● adb shell

– pm list packages -f● List of installed fqdn packages

● adb uninstall fqdn-package-name

Page 11: Introduction to google glass

Android Basic Components

● Resources● Activities● Services● Intents● Handlers● Logging

Page 12: Introduction to google glass

Resources● Layouts (xml)● Images (png)● Strings – i8n (xml)● Menus (xml)● Assets

Page 13: Introduction to google glass

Activity● self contained form

– with its own main thread to handle UI events● Derive from base class android.app.Activity● onCreate method● Other methods: onAttachedToWindow

Page 14: Introduction to google glass

Service● Derive class from base class android.app.Service● onStartCommand● onDestroy

Page 15: Introduction to google glass

Intent

To start an activity or service, and pass messages between activities/services

● Create Intent object, – Activity

● intent intAct = new intent(ctx, myActivity.class);

● startActivity(intAct);● startActivityForResult(intAct, iRequestCode);● onActivityResult(int requestCode, int

resultCode, Intent data)– resultCode == RESULT_OK–data.getData(), data.getStringExtra(),

data.get*()

– Service● intent intSrv = new intent(ctx,

myService.class);● startService(intSrv);● stopService(intSrv);

Page 16: Introduction to google glass

Handler● Async event handler● Executes in main thread● Uses

– Execute pending jobs in queue● Handler handler = new Handler();● handler.post(new Runnable() {…});

– Inter thread synchronization by main thread● Handler handler = new Handler() { @Override

handleMessage(...) }● handler.sendMessage(msg)

Page 17: Introduction to google glass

Log

Method– Log.i(tag, msg) → for info– Log.e(tag, msg) → for error

● DDMS Logcat– Set tag to filter messages from your application

or module

Page 18: Introduction to google glass

Glasswares and Glass Development

Glasswares and Glass Development

Page 19: Introduction to google glass

Application Types/Patterns

● GDK Glassware– Ongoing Task (Live Cards)– Immersion

● Mirror Glassware– Static Cards (notifications)

Page 20: Introduction to google glass

GDK Glasswares:Ongoing Tasks

GDK Glasswares:Ongoing Tasks

Page 21: Introduction to google glass

Ongoing Task

Service

Live Card

Menu (as activities)

Page 22: Introduction to google glass

Hands-onOngoing Tasks: HelloGlass

Hands-onOngoing Tasks: HelloGlass

Page 23: Introduction to google glass

HelloGlass:UX

Tap to start application

Tap to show menu

Page 24: Introduction to google glass

Life cards (Life cycle)

Page 25: Introduction to google glass

HelloGlass: Config

AndroidManifest.xml– android:versionCode– Uses-sdk

● Only 19 supported at this time

Page 26: Introduction to google glass

HelloGlass: Classes● HelloGlassService● HelloGlassView● HelloGlassViewUpdater● MenuActivity

Page 27: Introduction to google glass

Application Flow

Android Manifest HelloGlassService

Voice command intent

Service LiveCard ViewUpdater View

CreateRegisterCallback

MenuActivity

Attach using pending intent

PublishSurfaceCreated

SurfaceChanged Draw(Assign)

Page 28: Introduction to google glass

HelloGlassService● AndroidManifest.xml

– Application > service● android:name (src)● @string/app_name● Intent-filter● @xml/voice_trigger_start

● LiveCard– Register rendering callback (HelloGlassViewUpdater)– Attach Menu (MenuActivity)

Page 29: Introduction to google glass

HelloGlassView

● Load layout– @layout/card_hello.xml

● findViewById

Page 30: Introduction to google glass

HelloGlassViewUpdater● Callbacks

– SurfaceCreated– SurfaceChanged

● Now start updating view

Page 31: Introduction to google glass

MenuActivity● onAttachedToWindow● onCreateOptionsMenu● @menu/hello.xml● onOptionsItemSelected● onOptionsMenuClosed● Handler

Page 32: Introduction to google glass

GDK Glasswares:Immersion

GDK Glasswares:Immersion

Page 33: Introduction to google glass

Immersion● Pros

– Full control, left/right swipes● Cons

– Must close before moving to other card

Page 34: Introduction to google glass

Hands-on Immersion: GlassViewer

Hands-on Immersion: GlassViewer

Page 35: Introduction to google glass

GlassViewer: UX

Swipe left Swipe left

Swipe left

Swipe right Swipe right

Swipe right

Swipe Down

Tap

Start

Tap

Page 36: Introduction to google glass

GlassViewer● MainActivity

– onCreate● setContentView

– activity_main– mGestureDetector

● setBaseListener– onGesture

● SWIPE_LEFT, SWIPE_RIGHT, TAP, so on● onGenericMotionEvent

– Assets● getAssets().open

Page 37: Introduction to google glass

GDK Glasswares:Application Add-ons

GDK Glasswares:Application Add-ons

Page 38: Introduction to google glass

Voice Input● Commands List

– CALCULATE – START_A_STOPWATCH– START_IMAGING– Complete list:

● http://bit.ly/1jfwjaY

Page 39: Introduction to google glass

Touch Gestures● Gestures List

– LONG_PRESS– SWIPE_UP– TWO_LONG_PRESS– TWO_SWIPE_DOWN– TWO_TAP– Complete list:

● http://bit.ly/V3L4Ci

Page 40: Introduction to google glass

Camera

private static final int TAKE_PICTURE_REQUEST = 1;

private void takePicture() { Intent intent = new

Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent,

TAKE_PICTURE_REQUEST);}

@Overrideprotected void onActivityResult(int requestCode, int

resultCode, Intent data) { if (requestCode == TAKE_PICTURE_REQUEST &&

resultCode == RESULT_OK) { String picturePath = data.getStringExtra(

CameraManager.EXTRA_PICTURE_FILE_PATH); // Process picture: http://bit.ly/XGsyBW processPictureWhenReady(picturePath); }

super.onActivityResult(requestCode, resultCode, data);

}

Page 41: Introduction to google glass

Location Service● Obtain Location Manager

– LocationManager manager = getSystemService(Context.LOCATION_SERVICE);

● Create criteria (accuracy level/altitude required?)

– Criteria criteria = new Criteria();

– criteria.setAccuracy(Criteria.ACCURACY_FINE);

– criteria.setAltitudeRequired(true);

● Get providers list

– List<String> providers = locationManager.getProviders(

– criteria, true /* enabledOnly */);

● For each provider in List, get location updates

– locationManager.requestLocationUpdates(provider, 0,

– 0, location_listener);

Page 42: Introduction to google glass

Location Service: Listener● Create subclass of LocationListener to pass in

requestLocationUpdates

– public void onLocationChanged(Location location)● Location object

– double getLatitude() → Get the latitude, in degrees.– double getLongitude() → Get the longitude, in degrees.

Page 43: Introduction to google glass

Other sensors● Obtain sensor manager

– SensorManager mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

● Obtain specific sensor object

– Sensor mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);

● Register sensor listener

– mSensorManager.registerListener(sensor_listener, mSensor, SensorManager.SENSOR_DELAY_NORMAL);

Page 44: Introduction to google glass

Other sensors: Listener● Create subclass of SensorEventListener to pass in registerListener

– public final void onSensorChanged(SensorEvent event)● SensorEvent object

– float sensorVal = event.values[0];

Page 45: Introduction to google glass

Other sensors: List● TYPE_ACCELEROMETER

● TYPE_GYROSCOPE

● TYPE_LIGHT

● TYPE_MAGNETIC_FIELD

● For complete list: http://bit.ly/1u0gI2T

Page 46: Introduction to google glass

Recap of UI ElementsThe Glass user experience is based on 3 basic UI

elements• Static card:

– Displays text, HTML, images, and video. • Live card

– Used when users are actively engaged in a task– Do not persist in the timeline– Suited for real-time interaction with users

• Immersion– Displays Android activities that take over the timeline

experience

Page 47: Introduction to google glass

Design Patterns for Glassware

• GDK (Glass Development Kit)

• Mirror API

Page 48: Introduction to google glass

What is Mirror API?• Web-based services that interact with Google Glass• Over a cloud

• Does not require running code on Glass• User visits your web application from MyGlass and authenticates

• Your service sends cards to user as required

Page 49: Introduction to google glass

Why Mirror API?• Lets you use language of your choice

• Platform independence• Common infrastructure• Built-in functionality

Page 50: Introduction to google glass

When to use Mirror API?• Mirror API is great for delivering periodic

notifications to users as important things happen. • For example:

– News delivery service that sends the top news stories

– Our daily health tip service

Page 51: Introduction to google glass

How Mirror API Works?• Use RESTful services• Encapsulate data through

JSON• Authentication using

OAuth2• Standard POST, GET and

PUT methods for sending, listing and updating information

Page 52: Introduction to google glass

Example: Daily Health Tip• Daily Health Tips is implemented using Mirror API

– Users subscribe by authenticating with OAuth 2.0– Health Tips stores an index of users and their

credentials– New tip is published every day. It iterates through all

stored users and insert a timeline item into their timelines.

Page 53: Introduction to google glass

Inserting a New Static Card• When Glassware inserts static cards into the

timeline, Glass may play a notification sound to alert users.

Page 54: Introduction to google glass

Static Card• Reside to the right of the Glass clock by default• Display information to the user• Do not require immediate attention• Users can read or act on

the card at their own leisure

Page 55: Introduction to google glass

What Else Can You Do?• In addition, you can attach objects to a static card,

such as a location or media.• Insert timeline card with attachment

• Attach video

Page 56: Introduction to google glass

Bundling Cards• Distinguished with folded corner

Page 57: Introduction to google glass

Menu items• Menu items allow users to request actions that are

related to the timeline card.• Some Built-in menu items include:

– reading a timeline card aloud, – navigating to a location, – sharing an image, – replying to a message

Page 58: Introduction to google glass

Subscriptions

• The Mirror API allows you to subscribe to notifications that are sent when the user takes specific actions:– Reply– Delete– Custom menu item selected– Location update– Voice command

• When you subscribe to a notification, you provide a callback URL that processes the notification.

Page 59: Introduction to google glass

Design Principles for Glass

• Different than existing mobile platforms in both design and use. Follow these principles for best experience:– Design for Glass– Don't get in the way– Keep it relevant– Avoid the Unexpected

Page 60: Introduction to google glass

LET US NOW EXPLORE SOME GOOGLE GLASS APPS BY

10PEARLS

LET US NOW EXPLORE SOME GOOGLE GLASS APPS BY

10PEARLS

Page 61: Introduction to google glass

LIVE CAM TRACKERLIVE CAM TRACKER

Page 62: Introduction to google glass
Page 63: Introduction to google glass
Page 64: Introduction to google glass
Page 65: Introduction to google glass

HANGMANHANGMAN

Page 66: Introduction to google glass
Page 67: Introduction to google glass

BRICK BREAKERBRICK BREAKER

Page 68: Introduction to google glass
Page 69: Introduction to google glass

QUIZ TIME!QUIZ TIME!