SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
The Glass Class:
GDK – Live Cards
July 7th – 11th 2014
Mark Billinghurst, Gun Lee
HIT Lab NZ
University of Canterbury
An Introduction to
Glassware Development
GDK – Live Cards
Gun Lee
* Images in the slides are from variety of sources,
including http://developer.android.com and http://developers.google.com/glass
Live cards
- Native Glassware sitting on timeline
Live Cards
https://developers.google.com/glass/design/patterns
Creating a Live Card Project
 Start with normal Android Application Project
(same as Immersions)
 Minimum and Target SDK Versions: 19
 Compile with: GDK Preview
 Theme: None (allows the Glass theme to be applied.)
 Your main activity is now used for menu
 Rename MainActivity to MenuActivity
 Remove launcher/main intent filters from manifest
 Add Service as the main component
Creating a Live Card Project
 Add the main service component in the manifest
(next to activity) with voice trigger intent filter
<service
android:name=“org.hitlabnz.wailc.LiveCardMainService"
android:label="@string/app_name"
android:enabled="true"
android:exported="true“ >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/voice_trigger" />
</service>
Creating a Live Card Project
 Create the main service Java class
 File > New > Class
 Then in the dialog
- Give a name to your custom class
- Assign android.app.Service as the super class
public class LiveCardMainService extends Service {
@Override
public IBinder onBind(Intent arg0) {
return null;
}
}
Implement Live Card Service
 onStartCommand()
 Called when service is started
 Create a live card and publish it
 If a live card already exists, show it
 onDestroy()
 Called when service is destroyed
 Unpublish the live card
Implement Live Card Service
public int onStartCommand(Intent intent, int flags, int startId) {
if (mLiveCard == null) {
// create a live card
mLiveCard = new LiveCard(getApplicationContext(),
"SampleLiveCard");
... Setup rendering views & menu activity of the live card ...
// publish it
mLiveCard.publish(LiveCard.PublishMode.REVEAL);
// Use PublishMode.SILENT to not go to the live card
} else {
// show the existing live card
mLiveCard.navigate();
}
return Service.START_STICKY; // keep running
}
Implement Live Card Service
 Unpublish the live card in onDestroy()
@Override
public void onDestroy() {
if (mLiveCard != null) {
if(mLiveCard.isPublished())
mLiveCard.unpublish();
mLiveCard = null;
}
super.onDestroy();
}
Live Card Rendering
Low-Frequency Update
 < 1 fps
 Simpler to implement
 Limited set of type of
views supported
High-Frequency Update
 > 1 fps
 More code to implement
 More flexible
https://developers.google.com/glass/develop/gdk/ui/live-cards
Implement Low-Freq. Rendering
 Live Card Setup
 Update RemoteViews
mRemoteViews =
new RemoteViews(getPackageName(), R.layout.livecard)
mLiveCard.setViews(mRemoteViews);
* Layout can contain TextView, ImageView, Linear/Relative Layouts,
ProgressBar, etc.
http://developer.android.com/reference/android/widget/RemoteViews.html
https://developers.google.com/glass/develop/gdk/ui/live-cards
https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard
// update the subviews of the RemoteViews object
mRemoteViews.setTextViewText(R.id.textview1, “New Text”);
// trigger udpate
mLiveCard.setViews(mRemoteViews);
Implement High-Freq. Rendering
 Live Card Setup
 Draw view in DirectRendering callback
 Subclass of SurfaceHolder.Callback
- void renderingPaused(SurfaceHolder holder, boolean paused)
 Get SurfaceHolder in surfaceCreated()
 Run a thread for drawing
- Obtain a Canvas from the SurfaceHolder to draw on it
then release it when done
DirectRendering callback; // initialized somewhere else
mLiveCard.setDirectRenderingEnabled(true);
mLiveCard.getSurfaceHolder().addCallback(callback);
https://developers.google.com/glass/develop/gdk/ui/live-cards
https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard
Implement Live Card Menu Setup
 Make Live Card to start Menu Activity
when tapped on
// create intent to start MenuActivity
Intent menuIntent = new Intent(this, MenuActivity.class);
// ask live card to issue that intent when tapped on
mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0));
https://developers.google.com/glass/develop/gdk/ui/live-cards
https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard
Implement Menu Activity
 Menu activity should have no content
 Remove method onCreate()
 At least one menu item to close the Live Card
 Override onOptionsItemSelected() and call
stopService(new Intent(context, MyLiveCard.class))
 The menu activity should immediately show
menu after resumed, and finish when the menu
is closed
 Override onAttachedToWindow() and call
openOptionsMenu()
 Override onOptionsmenuClosed() and call finish()
https://developers.google.com/glass/develop/gdk/ui/live-card-menus
Implement Menu Activity
 Add style to make it transparent
 res/values/styles.xml
 Assign the style to the menu activity
component in the manifest
<style name="MenuTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@null</item>
</style>
<activity …
android:theme="@style/MenuTheme" >
https://developers.google.com/glass/develop/gdk/ui/live-card-menus
Live Demo
- Live Card with Counter
Location
 Setup LocationManager
 Location providers
- Glass might have different providers!
• Network, gps, remote
- Choose provider by criteria
 Setup listener and start listening
 Stop listening when done
 Add permission to the manifest file
https://developers.google.com/glass/develop/gdk/location-sensors/index
http://developer.android.com/guide/topics/location/index.html
Location
 Setup LocationManager and Start Listening
// get location manager
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
// get location providers by criteria
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
locationProviders = locationManager.getProviders(criteria, true /* enabledOnly */);
// start listening (request update to listener for each provider)
for (String provider : locationProviders) {
locationManager.requestLocationUpdates(provider,
1000, // update every 1 sec (1000 millisec)
50, // update every 50 meters
locationListener);
}
Location
 Setup Listener
LocationListener locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
// use your location information here
}
@Override
public void onProviderDisabled(String provider) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
};
Location
 Stop listening when done
 Add permission to the manifest file
locationManager.removeUpdates(locationListener);
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
* Or use ACCESS_COARSE_LOCATION if you don’t need more accurate providers
Live Demo
- Location
Sensors
 Sensors on available Glass
 Accelerometer, gyroscope, magnetic field,
 Gravity, linear acceleration, rotation vector
 Light
 Motion sensors located on the optic pod
 Be aware of battery life
 Only use when necessary
 Update frequency
https://developers.google.com/glass/develop/gdk/location-sensors/index
Sensors
 Setup SensorManager
 Get access to wanted type of sensor
 Various types of sensors
- Accelerometer, gyroscope, magnetic field,
- Gravity, linear acceleration, rotation vector
- Light
 Setup listener and start listening
 Stop listening when done
https://developers.google.com/glass/develop/gdk/location-sensors/index
http://developer.android.com/guide/topics/sensors/sensors_overview.html
Sensors
 Setup SensorManager
http://developer.android.com/guide/topics/sensors/sensors_overview.html
// setup sensor manager
SensorManager sensorManager =
(SensorManager)getSystemService(Context.SENSOR_SERVICE);
// get gravity sensor
Sensor gravitySensor =
sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
// start listening
if(gravitySensor != null)
sensorManager.registerListener(gravitySensorListener,
gravitySensor,
SensorManager.SENSOR_DELAY_NORMAL);
Sensors
 Setup Listener
SensorEventListener gravitySensorListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
float[] gravityValue = event.values;
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
};
http://developer.android.com/guide/topics/sensors/sensors_motion.html
http://developer.android.com/guide/topics/sensors/sensors_overview.html
Sensors
 Stop listening when done
http://developer.android.com/guide/topics/sensors/sensors_overview.html
sensorManager.unregisterListener(gravitySensorListener);
Live Demo
- Sensors
Richer Live Cards
https://developers.google.com/glass/design/patterns
Sample Apps in SDK
 File > New Project > Android Sample
Project
 Choose build target to GDK
 Stopwatch
 Timer
 Compass
GDK
 Glass Development Kit
 Android 4.4.2 + Glass specific APIs
 Sneak peek preview
 Look for more components in Android SDK
 http://developer.android.com
Summary
 Use Mirror API if you need ...
 Use GDK if you need ...
 Or use both
More Information
 Website
 https://developers.google.com/glass
 http://arforglass.org
 http://www.hitlabnz.org
 Gun Lee
 gun.lee@hitlabnz.org
 Mark Billinghurst
 mark.billinghurst@hitlabnz.org

Contenu connexe

Tendances

Android chapter25-map views
Android chapter25-map viewsAndroid chapter25-map views
Android chapter25-map viewsTran Le Hoan
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycleAhsanul Karim
 
Ch10 - Programming for Touchscreens and Mobile Devices
Ch10 - Programming for Touchscreens and Mobile DevicesCh10 - Programming for Touchscreens and Mobile Devices
Ch10 - Programming for Touchscreens and Mobile Devicesdcomfort6819
 
The Glass Class - Tutorial 3 - Android and GDK
The Glass Class - Tutorial 3 - Android and GDKThe Glass Class - Tutorial 3 - Android and GDK
The Glass Class - Tutorial 3 - Android and GDKGun Lee
 
What's new in Android Lollipop
What's new in Android LollipopWhat's new in Android Lollipop
What's new in Android LollipopAbdellah SELASSI
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & viewsma-polimi
 
Developing Google Glass
Developing Google GlassDeveloping Google Glass
Developing Google GlassJohnny Sung
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation ComponentŁukasz Ciupa
 
Android apps development
Android apps developmentAndroid apps development
Android apps developmentRaman Pandey
 
mDevcon tour 2014 beyondar
mDevcon tour 2014 beyondarmDevcon tour 2014 beyondar
mDevcon tour 2014 beyondarJoan Puig Sanz
 
Android studio
Android studioAndroid studio
Android studioAndri Yabu
 
UIViewControllerのコーナーケース
UIViewControllerのコーナーケースUIViewControllerのコーナーケース
UIViewControllerのコーナーケースKatsumi Kishikawa
 

Tendances (18)

Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Android chapter25-map views
Android chapter25-map viewsAndroid chapter25-map views
Android chapter25-map views
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
 
Ch10 - Programming for Touchscreens and Mobile Devices
Ch10 - Programming for Touchscreens and Mobile DevicesCh10 - Programming for Touchscreens and Mobile Devices
Ch10 - Programming for Touchscreens and Mobile Devices
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Android classes in mumbai
Android classes in mumbaiAndroid classes in mumbai
Android classes in mumbai
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
The Glass Class - Tutorial 3 - Android and GDK
The Glass Class - Tutorial 3 - Android and GDKThe Glass Class - Tutorial 3 - Android and GDK
The Glass Class - Tutorial 3 - Android and GDK
 
What's new in Android Lollipop
What's new in Android LollipopWhat's new in Android Lollipop
What's new in Android Lollipop
 
Activity
ActivityActivity
Activity
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
Developing Google Glass
Developing Google GlassDeveloping Google Glass
Developing Google Glass
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation Component
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
mDevcon tour 2014 beyondar
mDevcon tour 2014 beyondarmDevcon tour 2014 beyondar
mDevcon tour 2014 beyondar
 
Android studio
Android studioAndroid studio
Android studio
 
UIViewControllerのコーナーケース
UIViewControllerのコーナーケースUIViewControllerのコーナーケース
UIViewControllerのコーナーケース
 

Similaire à The Glass Class - Tutorial 4 - GDK-Live Cards

Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
Google Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer ZoneGoogle Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer ZoneUtpal Betai
 
Introduction to google glass
Introduction to google glassIntroduction to google glass
Introduction to google glassAnees Haider
 
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...LogeekNightUkraine
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalChris Griffith
 
Developing AIR for Android with Flash Professional CS5
Developing AIR for Android with Flash Professional CS5Developing AIR for Android with Flash Professional CS5
Developing AIR for Android with Flash Professional CS5Chris Griffith
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updatedGhanaGTUG
 
Invading the home screen
Invading the home screenInvading the home screen
Invading the home screenMatteo Bonifazi
 
Gradle for Android Developers
Gradle for Android DevelopersGradle for Android Developers
Gradle for Android DevelopersJosiah Renaudin
 
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Fabio Biondi
 
Google Glass, the GDK, and HTML5
Google Glass, the GDK, and HTML5Google Glass, the GDK, and HTML5
Google Glass, the GDK, and HTML5Oswald Campesato
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Gabor Varadi
 
Building Glassware with the Glass Development Kit
Building Glassware with the Glass Development KitBuilding Glassware with the Glass Development Kit
Building Glassware with the Glass Development KitEveryware Technologies
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5Chris Griffith
 

Similaire à The Glass Class - Tutorial 4 - GDK-Live Cards (20)

Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
Google Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer ZoneGoogle Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer Zone
 
Introduction to google glass
Introduction to google glassIntroduction to google glass
Introduction to google glass
 
@Ionic native/google-maps
@Ionic native/google-maps@Ionic native/google-maps
@Ionic native/google-maps
 
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash Professional
 
Developing AIR for Android with Flash Professional CS5
Developing AIR for Android with Flash Professional CS5Developing AIR for Android with Flash Professional CS5
Developing AIR for Android with Flash Professional CS5
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
Invading the home screen
Invading the home screenInvading the home screen
Invading the home screen
 
Gradle for Android Developers
Gradle for Android DevelopersGradle for Android Developers
Gradle for Android Developers
 
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)
 
Google Glass, the GDK, and HTML5
Google Glass, the GDK, and HTML5Google Glass, the GDK, and HTML5
Google Glass, the GDK, and HTML5
 
Introduction toandroid
Introduction toandroidIntroduction toandroid
Introduction toandroid
 
Android 3
Android 3Android 3
Android 3
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
Building Glassware with the Glass Development Kit
Building Glassware with the Glass Development KitBuilding Glassware with the Glass Development Kit
Building Glassware with the Glass Development Kit
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5
 
Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 

Dernier

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Dernier (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

The Glass Class - Tutorial 4 - GDK-Live Cards

  • 1. The Glass Class: GDK – Live Cards July 7th – 11th 2014 Mark Billinghurst, Gun Lee HIT Lab NZ University of Canterbury
  • 2. An Introduction to Glassware Development GDK – Live Cards Gun Lee * Images in the slides are from variety of sources, including http://developer.android.com and http://developers.google.com/glass
  • 3. Live cards - Native Glassware sitting on timeline
  • 5. Creating a Live Card Project  Start with normal Android Application Project (same as Immersions)  Minimum and Target SDK Versions: 19  Compile with: GDK Preview  Theme: None (allows the Glass theme to be applied.)  Your main activity is now used for menu  Rename MainActivity to MenuActivity  Remove launcher/main intent filters from manifest  Add Service as the main component
  • 6. Creating a Live Card Project  Add the main service component in the manifest (next to activity) with voice trigger intent filter <service android:name=“org.hitlabnz.wailc.LiveCardMainService" android:label="@string/app_name" android:enabled="true" android:exported="true“ > <intent-filter> <action android:name="com.google.android.glass.action.VOICE_TRIGGER" /> </intent-filter> <meta-data android:name="com.google.android.glass.VoiceTrigger" android:resource="@xml/voice_trigger" /> </service>
  • 7. Creating a Live Card Project  Create the main service Java class  File > New > Class  Then in the dialog - Give a name to your custom class - Assign android.app.Service as the super class public class LiveCardMainService extends Service { @Override public IBinder onBind(Intent arg0) { return null; } }
  • 8. Implement Live Card Service  onStartCommand()  Called when service is started  Create a live card and publish it  If a live card already exists, show it  onDestroy()  Called when service is destroyed  Unpublish the live card
  • 9. Implement Live Card Service public int onStartCommand(Intent intent, int flags, int startId) { if (mLiveCard == null) { // create a live card mLiveCard = new LiveCard(getApplicationContext(), "SampleLiveCard"); ... Setup rendering views & menu activity of the live card ... // publish it mLiveCard.publish(LiveCard.PublishMode.REVEAL); // Use PublishMode.SILENT to not go to the live card } else { // show the existing live card mLiveCard.navigate(); } return Service.START_STICKY; // keep running }
  • 10. Implement Live Card Service  Unpublish the live card in onDestroy() @Override public void onDestroy() { if (mLiveCard != null) { if(mLiveCard.isPublished()) mLiveCard.unpublish(); mLiveCard = null; } super.onDestroy(); }
  • 11. Live Card Rendering Low-Frequency Update  < 1 fps  Simpler to implement  Limited set of type of views supported High-Frequency Update  > 1 fps  More code to implement  More flexible https://developers.google.com/glass/develop/gdk/ui/live-cards
  • 12. Implement Low-Freq. Rendering  Live Card Setup  Update RemoteViews mRemoteViews = new RemoteViews(getPackageName(), R.layout.livecard) mLiveCard.setViews(mRemoteViews); * Layout can contain TextView, ImageView, Linear/Relative Layouts, ProgressBar, etc. http://developer.android.com/reference/android/widget/RemoteViews.html https://developers.google.com/glass/develop/gdk/ui/live-cards https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard // update the subviews of the RemoteViews object mRemoteViews.setTextViewText(R.id.textview1, “New Text”); // trigger udpate mLiveCard.setViews(mRemoteViews);
  • 13. Implement High-Freq. Rendering  Live Card Setup  Draw view in DirectRendering callback  Subclass of SurfaceHolder.Callback - void renderingPaused(SurfaceHolder holder, boolean paused)  Get SurfaceHolder in surfaceCreated()  Run a thread for drawing - Obtain a Canvas from the SurfaceHolder to draw on it then release it when done DirectRendering callback; // initialized somewhere else mLiveCard.setDirectRenderingEnabled(true); mLiveCard.getSurfaceHolder().addCallback(callback); https://developers.google.com/glass/develop/gdk/ui/live-cards https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard
  • 14. Implement Live Card Menu Setup  Make Live Card to start Menu Activity when tapped on // create intent to start MenuActivity Intent menuIntent = new Intent(this, MenuActivity.class); // ask live card to issue that intent when tapped on mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0)); https://developers.google.com/glass/develop/gdk/ui/live-cards https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard
  • 15. Implement Menu Activity  Menu activity should have no content  Remove method onCreate()  At least one menu item to close the Live Card  Override onOptionsItemSelected() and call stopService(new Intent(context, MyLiveCard.class))  The menu activity should immediately show menu after resumed, and finish when the menu is closed  Override onAttachedToWindow() and call openOptionsMenu()  Override onOptionsmenuClosed() and call finish() https://developers.google.com/glass/develop/gdk/ui/live-card-menus
  • 16. Implement Menu Activity  Add style to make it transparent  res/values/styles.xml  Assign the style to the menu activity component in the manifest <style name="MenuTheme" parent="@android:style/Theme.DeviceDefault"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle">@null</item> </style> <activity … android:theme="@style/MenuTheme" > https://developers.google.com/glass/develop/gdk/ui/live-card-menus
  • 17. Live Demo - Live Card with Counter
  • 18. Location  Setup LocationManager  Location providers - Glass might have different providers! • Network, gps, remote - Choose provider by criteria  Setup listener and start listening  Stop listening when done  Add permission to the manifest file https://developers.google.com/glass/develop/gdk/location-sensors/index http://developer.android.com/guide/topics/location/index.html
  • 19. Location  Setup LocationManager and Start Listening // get location manager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); // get location providers by criteria Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); locationProviders = locationManager.getProviders(criteria, true /* enabledOnly */); // start listening (request update to listener for each provider) for (String provider : locationProviders) { locationManager.requestLocationUpdates(provider, 1000, // update every 1 sec (1000 millisec) 50, // update every 50 meters locationListener); }
  • 20. Location  Setup Listener LocationListener locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { // use your location information here } @Override public void onProviderDisabled(String provider) {} @Override public void onProviderEnabled(String provider) {} @Override public void onStatusChanged(String provider, int status, Bundle extras) {} };
  • 21. Location  Stop listening when done  Add permission to the manifest file locationManager.removeUpdates(locationListener); <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> * Or use ACCESS_COARSE_LOCATION if you don’t need more accurate providers
  • 23. Sensors  Sensors on available Glass  Accelerometer, gyroscope, magnetic field,  Gravity, linear acceleration, rotation vector  Light  Motion sensors located on the optic pod  Be aware of battery life  Only use when necessary  Update frequency https://developers.google.com/glass/develop/gdk/location-sensors/index
  • 24. Sensors  Setup SensorManager  Get access to wanted type of sensor  Various types of sensors - Accelerometer, gyroscope, magnetic field, - Gravity, linear acceleration, rotation vector - Light  Setup listener and start listening  Stop listening when done https://developers.google.com/glass/develop/gdk/location-sensors/index http://developer.android.com/guide/topics/sensors/sensors_overview.html
  • 25. Sensors  Setup SensorManager http://developer.android.com/guide/topics/sensors/sensors_overview.html // setup sensor manager SensorManager sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); // get gravity sensor Sensor gravitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); // start listening if(gravitySensor != null) sensorManager.registerListener(gravitySensorListener, gravitySensor, SensorManager.SENSOR_DELAY_NORMAL);
  • 26. Sensors  Setup Listener SensorEventListener gravitySensorListener = new SensorEventListener() { @Override public void onSensorChanged(SensorEvent event) { float[] gravityValue = event.values; } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) {} }; http://developer.android.com/guide/topics/sensors/sensors_motion.html http://developer.android.com/guide/topics/sensors/sensors_overview.html
  • 27. Sensors  Stop listening when done http://developer.android.com/guide/topics/sensors/sensors_overview.html sensorManager.unregisterListener(gravitySensorListener);
  • 30. Sample Apps in SDK  File > New Project > Android Sample Project  Choose build target to GDK  Stopwatch  Timer  Compass
  • 31. GDK  Glass Development Kit  Android 4.4.2 + Glass specific APIs  Sneak peek preview  Look for more components in Android SDK  http://developer.android.com
  • 32. Summary  Use Mirror API if you need ...  Use GDK if you need ...  Or use both
  • 33. More Information  Website  https://developers.google.com/glass  http://arforglass.org  http://www.hitlabnz.org  Gun Lee  gun.lee@hitlabnz.org  Mark Billinghurst  mark.billinghurst@hitlabnz.org