android workshop - 02. glass development 101
TRANSCRIPT
https://plus.google.com/+RobertWarren/posts/6EHpFkzz51v?pid=6106039615307089474&oid=113334680236721862429
http://zwallpaper.biz/hinhanh/anhto/131213sad-white-puppy-wallpaper.jpg http://techcrunch.com/2015/01/19/today-is-the-last-day-to-buy-google-glass/
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
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
Immersion Example• CardBuilder
• SoundEffect
• CardScrollView
• CardScrollAdapter
• onItemClick
Mmm… It’s too diffcult.
Do some changes2. Edit files
• Change ActionBarActivity to Activity (MainActivity.java)
• Remove android:theme(AndroidManifest.xml)
• Remove unused padding’s var (activity_main.xml)
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
package com.johnny.petstarglass;
import android.app.Activity;import android.os.Bundle;
public class MainActivity extends Activity {
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);setContentView(R.layout.card_main);
}}
MainActivity.javaCopy from android app’s
Change this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
Remove this
Change to LinearLayout
activity_main.xml
<?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
<?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
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
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
public class MainActivity extends Activity {
@Overrideprotected 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
SoundEffect
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.playSoundEffect(Sounds.DISALLOWED);
SoundEffect
https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/media/Sounds
Touch input
Swipe down translates to KEYCODE_BACK.
A camera button press translates to KEYCODE_CAMERA.
Tap translates to KEYCODE_DPAD_CENTER.
Touch input@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_CAMERA) {// ...return true;
}return false;
}
@Overridepublic boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_CAMERA) {// ...return true;
}return false;
}
MainActivity.java
Where To Go From Here?
• Check the development guide https://developers.google.com/glass/develop/gdk/index
• Touch Gestures
• Card Scroller
• Slider
• Live Cards
http://fb.com/groups/glassdev.taiwanGoogle glass developer Taiwan
不只聊 Glass 喔