Google Glass Live Card does not insert

GDK glass is here. Trying to insert a livecard using remote views from the service. I start the service using a voice call. The voice command works, however, it seems that my service does not start (there are no log entries). Service in android manifest. Below is the code:

public class PatientLiveCardService extends Service {

private static final String LIVE_CARD_ID = "timer";


@Override
public void onCreate() {
    Log.warn("oncreate");
    super.onCreate();
}

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    publishCard(this);

    return START_STICKY;
}

@Override
public void onDestroy() {
    unpublishCard(this);
    super.onDestroy();
}



private void publishCard(Context context) {
    Log.info("inserting live card");
    if (mLiveCard == null) {
        String cardId = "my_card";
        TimelineManager tm = TimelineManager.from(context);
        mLiveCard = tm.getLiveCard(cardId);

        mLiveCard.setViews(new RemoteViews(context.getPackageName(),
                R.layout.activity_vitals));
        Intent intent = new Intent(context, MyActivity.class);
        mLiveCard.setAction(PendingIntent
                .getActivity(context, 0, intent, 0));
        mLiveCard.publish();
    } else {
        // Card is already published.
        return;
    }
}

private void unpublishCard(Context context) {
    if (mLiveCard != null) {
        mLiveCard.unpublish();
        mLiveCard = null;
    }
}

}

Here is AndroidManifest.xml:

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

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

<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO" >
</uses-permission>

<application
    android:name="com.myApp"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
      <activity
        android:name="com.myApp.MyActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
    </activity>

    <service android:name="com.myApp.services.MyService" 
         android:enabled="true"
         android:exported="true">
        <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_get_patient" />
    </service>

</application>

+4
source share
1 answer

This is a bug with XE11: the service does not start after speech recognition is complete.

As a workaround, you can start a voice start Activity, which:

  • Performs recognized speech at onResume.
  • After speech processing begins Servicewith startService.
  • finish, LiveCard.
+4

All Articles