0

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>

Kratika Singh
  • 23
  • 1
  • 6

1 Answers1

0

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.

straya
  • 5,002
  • 1
  • 28
  • 35
  • onStartCommand gets called for the first time when our application gets started or when user scrolls ayaya and chooses the menu that corresponds to our card.Correct me if m wrong on this.Also 1 more thing that in service class when m creating an intent i am passing the reference of MenuActivity.class(that is my activity class) since i want to attach the menu in my live card and in some videos i have seen the reference of service class.So what is the reason for that. – Kratika Singh Oct 01 '14 at 09:13
  • I am also using voice trigger to run it through voice command.So only the voice trigger that are available i mean that are official only that can be used to trigger our app through voice commands.Or we can use our commands in Voice_trigger.xml file. – Kratika Singh Oct 01 '14 at 09:19
  • you should focus on a single problem by isolating it. In this case your problem is the LiveCard is not displaying, so focus on that and remove external factors such as Voice Triggers and the nature of the Intent you want to build. Sounds like you're assuming that the Service starts, not seeing it start - use logging to be sure. – straya Oct 01 '14 at 12:48
  • I got the solution.The problem was the voice trigger.Only the voice triggers that are official only those can be used. – Kratika Singh Oct 06 '14 at 06:06
  • How can we create a list view in google glass??For eg if we want to display a list of items after clicking on a particular option. – Kratika Singh Oct 06 '14 at 06:08
  • it is possible to use unofficial voice triggers, using the developer permission: https://developers.google.com/glass/develop/gdk/voice#unlisted_commands – straya Oct 06 '14 at 13:14
  • Any other questions ---> make a new StackOverflow question. Please mark my question correct as I helped you to break down your problems and find that the problem was elsewhere. – straya Oct 06 '14 at 13:15
  • yes but that need some time for using our voice triggers.We need to register that. – Kratika Singh Oct 07 '14 at 10:11