Search code examples
androidgoogle-glassgoogle-gdk

Issue while creating live card on google glass. Card not getting displayed


How to display live card on google glass??What can be the issues that need to take care of specially while developing live card.I have created one but its not working.Here is my code for service

    public int onStartCommand(Intent intent, int flags, int startId) {
    // TODO Auto-generated method stub

    if (livecard == null) {
        livecard = new LiveCard(this, "tag");

        // live card view
        remote = new RemoteViews(getPackageName(),
                com.example.livecardnew.R.layout.live_card);
        livecard.setViews(remote);

        // live card menu activity
        Intent menuIntent = new Intent(this, MenuActivity.class);
        menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TASK);

        // issue ths card when tapped
        livecard.setAction(PendingIntent.getActivity(this, 100, menuIntent,
                0));

        livecard.publish(LiveCard.PublishMode.REVEAL);
    }

    else {
        livecard.navigate();
    }
    return Service.START_STICKY;
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.livecardnew"
android:versionCode="1"
android:versionName="1.0" >

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

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

    <!-- android:theme="@style/AppTheme" -->

    <activity
        android:name=".MenuActivity"
        android:label="@string/app_name" >

    </activity>

    <service
        android:name="com.example.livecardnew.MyService"
        android:enabled="true"
        android:exported="true"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <meta-data
            android:name="com.google.android.glass.VoiceTrigger"
            android:resource="@xml/voice_trigger" />
    </service>
</application>


Solution

  • It is undocumented, but you MUST add an intent (using setAction method) to the LiveCard otherwise it won't be displayed...which you are doing...so it's not that.

    Are you 100% sure that onStartCommand is being called and your logic is working to reach the code that should setup and display the LiveCard? Get methodical and put some logging in, perhaps.