Search code examples
google-glassgoogle-gdk

Google Glass: Card not being displayed


Need help to display a sample card in the glass timeline(refer image). All i need is to launch the card when one taps when "ok glass" is displayed and scroll to view the card(image 2), the same via voice command also does not work. I tried launching the same activity via adb shell it works perfectly fine, also i added an intent filter with MAIN/LAUNCHER category to the activity - it runs. I referred this link for this POC but nothing like the image is being displayed. Please help as to where am i going wrong - TIA

Activity:

package de.androidzeitgeist.glass.helloworld.immersion;

import android.app.Activity;
import android.os.Bundle;

import com.google.android.glass.app.Card;

public class HelloWorldActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    Card card = new Card(this);
    card.setText("Hello world!");
    card.setFootnote("android.com");

    setContentView(cardroid.getView());
    }
}

Manifest File:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.androidzeitgeist.glass.helloworld.immersion"
    android:versionCode="1"
    android:versionName="1.0" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/helloworld_icon"
        android:label="@string/app_name" >

        <activity
            android:name="de.androidzeitgeist.glass.helloworld.immersion.HelloWorldActivity"
            android:icon="@drawable/helloworld_icon"
            android:label="@string/app_name" >
            <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" />
        </activity>
    </application>

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19" />

</manifest>

voice_trigger.xml

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/show_hello_word" />

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">HelloWorldImmersion</string>
    <string name="hello_world"></string>

    <string name="show_hello_word">show hello world</string>

</resources>

Solution

  • If you are using an unregistered voice command, your manifest.xml must include

    <uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
    

    See https://developers.google.com/glass/develop/gdk/starting-glassware for more details about using registered commands and unlisted commands and Why is my voice command missing from the ok glass menu in XE16? for some clarification and examples.