Reputation: 70
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;
}
Upvotes: 0
Views: 393
Reputation: 6034
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
.
Immersion Activity
or the Simple Live Card
templateUpvotes: 0
Reputation: 70
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.
Upvotes: 1