0

I'm trying to build a simple Hello World GDK program for Google Glass. I've looked up everywhere, but all the samples I could find used "Timeline Manager", which was removed by Google after XE 16.

What I'm trying to do is to create a live card that shows texts (Hello world!) in the middle. I've tried to modify codes from HERE (HuskyHuskie's answer) and HERE (IsabelHM's answer)

However, no matter what I did, no option or voice command appeared on the glass even though the console showed that the program is installed on device.

What I mostly modified was take out the TimelineManager part and replace

mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_ID); with mLiveCard = new LiveCard(this,LIVE_CARD_ID);

Also, I'm relatively new to Android. I don't quite understand how R.id.XXXX and R.layout.XXXX are missing from the resource. Do you need to define it in Manifest or what else?

The following is the onStartCommand method:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
            RemoteViews aRV = new RemoteViews(this.getPackageName(),
            R.layout.card_text);
    if (mLiveCard == null) {
       // mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
        mLiveCard = new LiveCard(this,LIVE_CARD_ID);

        aRV.setTextViewText(R.id.main_text, INTRO);
        mLiveCard.setViews(aRV);



        Intent mIntent = new Intent(this, MainActivity.class);
        mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |    Intent.FLAG_ACTIVITY_CLEAR_TASK);
        mLiveCard.setAction(PendingIntent.getActivity(this, 0, mIntent, 0));
        mLiveCard.publish(LiveCard.PublishMode.REVEAL);
    } 
    return START_STICKY;
}
Community
  • 1
  • 1
JavaMaMocha
  • 70
  • 1
  • 10

2 Answers2

1

Ok I got it to work following THIS

Note that the Manifest is not entirely correct. You need to add this line in the Manifest after the XE16 update:

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

See the post HERE for reference.

Community
  • 1
  • 1
JavaMaMocha
  • 70
  • 1
  • 10
0

I strongly recommend using our official samples available on GitHub and reading our documentations as all of those caveats are explained and handled.

If you are using the latest version of Android Studio, you can also easily create a new project through our available templates: LiveCard and Immersion.

  1. Open Android Studio
  2. Create a new project
  3. Enter your project information: application name, package name, etc.
  4. Select Glass as the form factor: make sure to unselect all the other form factors unless you want to develop for those devices as well.
  5. Select the Immersion Activity or the Simple Live Card template
  6. Build and run your new Hello World project on Glass!
Alain
  • 6,044
  • 19
  • 27