Ok Glass... Make me a Sandwich (with code samples)
-
Upload
luis-gv -
Category
Technology
-
view
511 -
download
0
Transcript of Ok Glass... Make me a Sandwich (with code samples)
Glassware, ¿qué aporta?Inmediatez
Relevancia
Contexto
Fácil y rápido
Sólo información relevante
No te metas en medio
¿Cómo puedes hacer esto?
Android+
Glass Development Kit
Glass Development Kit
Instalar GDK
Componentes GDK1. Timeline
2. Live Card
3. Static Card
4. Immersion
5. Menús(*)
6. CardScroll: Adapter + View
7. Voice Trigger
GDK: TimelinePresente y futuro
Pasado
GDK: Static Card// Create with current context
Card mCard = new Card(mContext);
mCard.setText("Esto es una static card");
mCard.setFootnote("Y esto es su footer!");
// Add card to timeline
TimelineManager.from(mContext).insert(mCard);
GDK: Live Card
GDK: Live Card// Create livecard using TimelineManager
mLiveCard = TimelineManager.from(mContext).createLiveCard(LIVE_CARD_SAMPLE_1_TAG);
// Set and save live card remote view to modify it later
mLiveCardRemoveViews = new RemoteViews(getPackageName(), R.layout.livecard1);
mLiveCard.setViews(mLiveCardRemoveViews);
// Publish livecard in REVEAL mode (alternative to SILENT mode)
// Set a PendingIntent to handle livecard actions (like a menu)
Intent intent = new Intent(mContext, MenuActivity.class);
mLiveCard.setAction(PendingIntent.getActivity(mContext, 0, intent, 0));
mLiveCard.publish(LiveCard.PublishMode.REVEAL);
GDK: Immersion
GDK: Immersionpublic class GlassSampleImmersion extends Activity { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);setContentView(R.layout.immersion);
} public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu as usualMenuInflater inflater = getMenuInflater();inflater.inflate(R.menu.sample3menu, menu);return true;
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Capture tap to display menuif (keyCode == KeyEvent.
KEYCODE_DPAD_CENTER) {openOptionsMenu();
return true;}return false;
}}
GDK: Menús
GDK: CardScrollListView ArrayAdapter
CardScrollView CardScrollAdapter
GDK: CardScroll protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create array of sample cards to use in the adapter
createCards();
// Create view programmatically
mCardScrollView = new CardScrollView(mContext);
CardScrollAdapter adapter = new MyCardAdapter();
mCardScrollView.setAdapter(adapter);
// Important! Views are NOT active by default
mCardScrollView.activate();
// Set activity view as usual
setContentView(mCardScrollView);
}
private class MyCardAdapter extends CardScrollAdapter {
(...)
public View getView(int position, View convertView,
ViewGroup parent) {
// Cards are able to render themselves
return mCards.get(position).toView();
}
}
GDK: Voice Trigger
ok glass,
get directions to…send a message to…make a call to…play music...
ok glass, play music… which artist?
Voice Trigger Voice Trigger Prompt
GDK: Voice Trigger<?xml version="1.0" encoding="utf-8"?><resources> <string name="glass_voice_trigger">play music</string></resources>
1) res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?><trigger keyword="@string/glass_voice_trigger" />
2) res/xml/myTrigger.xml
<activity | service ...><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/myTrigger" />
</activity | service>
3) AndroidManifest.xml
GDK: Voice Trigger (Prompt)<?xml version="1.0" encoding="utf-8"?><resources> <string name="glass_voice_trigger">play music</string> <string name="glass_voice_prompt">which artist?</string></resources>
1) res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?><trigger keyword="@string/glass_voice_trigger"> <input prompt="@string/glass_voice_prompt" /></trigger>
2) res/xml/myTrigger.xml
protected void onResume() {
super.onResume();
ArrayList<String> voiceResults = getIntent().getExtras().getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
}
3) Your Glassware Activity
Algunos ejemplos(Código disponible en https://github.com/lgvalle/Glass)
¿Qué cosas no puedo hacer?(Hoy, 20 de Marzo de 2014)
No es posible- Reconocimiento facial
- Submenús de voz
- Reconocimiento de voz offline
- Google Play Services: GCM, Google Maps API v2, new
Location APIs…
- Lanzar apps del teléfono
getLiveCard() is now createLiveCard()- XE12 - 17 Diciembre 2013
- XE11 - 11 Noviembre 2013
- XE10 - 7 Octubre 2013
Inspiración
HackathonDesafío BBVA Desafío
TelepizzaDesafío Estrella
Damm
10 equipos 10 equipos 10 equipos
Equipo
Tres personasNombre de equipocom.hackathon.<desafio>.<equipo>
Google Glass2 unidades por salaRotan cada 5 minutos
Make it happen!