Introduction to google glass
-
Upload
anees-haider -
Category
Software
-
view
206 -
download
2
description
Transcript of Introduction to google glass
PRESENTING GOOGLE GLASSPRESENTING
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
Glass Components
Glass Experience
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
Software Stack
AndroidSubsystem
GlassSubsystem
Glassware
Quick look at Android Development
Quick look at Android Development
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
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)
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
Android Basic Components
● Resources● Activities● Services● Intents● Handlers● Logging
Resources● Layouts (xml)● Images (png)● Strings – i8n (xml)● Menus (xml)● Assets
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
Service● Derive class from base class android.app.Service● onStartCommand● onDestroy
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);
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)
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
Glasswares and Glass Development
Glasswares and Glass Development
Application Types/Patterns
● GDK Glassware– Ongoing Task (Live Cards)– Immersion
● Mirror Glassware– Static Cards (notifications)
GDK Glasswares:Ongoing Tasks
GDK Glasswares:Ongoing Tasks
Ongoing Task
Service
Live Card
Menu (as activities)
Hands-onOngoing Tasks: HelloGlass
Hands-onOngoing Tasks: HelloGlass
HelloGlass:UX
Tap to start application
Tap to show menu
Life cards (Life cycle)
HelloGlass: Config
AndroidManifest.xml– android:versionCode– Uses-sdk
● Only 19 supported at this time
HelloGlass: Classes● HelloGlassService● HelloGlassView● HelloGlassViewUpdater● MenuActivity
Application Flow
Android Manifest HelloGlassService
Voice command intent
Service LiveCard ViewUpdater View
CreateRegisterCallback
MenuActivity
Attach using pending intent
PublishSurfaceCreated
SurfaceChanged Draw(Assign)
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)
HelloGlassView
● Load layout– @layout/card_hello.xml
● findViewById
HelloGlassViewUpdater● Callbacks
– SurfaceCreated– SurfaceChanged
● Now start updating view
MenuActivity● onAttachedToWindow● onCreateOptionsMenu● @menu/hello.xml● onOptionsItemSelected● onOptionsMenuClosed● Handler
GDK Glasswares:Immersion
GDK Glasswares:Immersion
Immersion● Pros
– Full control, left/right swipes● Cons
– Must close before moving to other card
Hands-on Immersion: GlassViewer
Hands-on Immersion: GlassViewer
GlassViewer: UX
Swipe left Swipe left
Swipe left
Swipe right Swipe right
Swipe right
Swipe Down
Tap
Start
Tap
GlassViewer● MainActivity
– onCreate● setContentView
– activity_main– mGestureDetector
● setBaseListener– onGesture
● SWIPE_LEFT, SWIPE_RIGHT, TAP, so on● onGenericMotionEvent
– Assets● getAssets().open
GDK Glasswares:Application Add-ons
GDK Glasswares:Application Add-ons
Voice Input● Commands List
– CALCULATE – START_A_STOPWATCH– START_IMAGING– Complete list:
● http://bit.ly/1jfwjaY
Touch Gestures● Gestures List
– LONG_PRESS– SWIPE_UP– TWO_LONG_PRESS– TWO_SWIPE_DOWN– TWO_TAP– Complete list:
● http://bit.ly/V3L4Ci
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);
}
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);
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.
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);
Other sensors: Listener● Create subclass of SensorEventListener to pass in registerListener
– public final void onSensorChanged(SensorEvent event)● SensorEvent object
– float sensorVal = event.values[0];
Other sensors: List● TYPE_ACCELEROMETER
● TYPE_GYROSCOPE
● TYPE_LIGHT
● TYPE_MAGNETIC_FIELD
● For complete list: http://bit.ly/1u0gI2T
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
Design Patterns for Glassware
• GDK (Glass Development Kit)
• Mirror API
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
Why Mirror API?• Lets you use language of your choice
• Platform independence• Common infrastructure• Built-in functionality
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
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
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.
Inserting a New Static Card• When Glassware inserts static cards into the
timeline, Glass may play a notification sound to alert users.
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
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
Bundling Cards• Distinguished with folded corner
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
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.
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
LET US NOW EXPLORE SOME GOOGLE GLASS APPS BY
10PEARLS
LET US NOW EXPLORE SOME GOOGLE GLASS APPS BY
10PEARLS
LIVE CAM TRACKERLIVE CAM TRACKER
HANGMANHANGMAN
BRICK BREAKERBRICK BREAKER
QUIZ TIME!QUIZ TIME!