[英]Hello World For Google Glass
I'm trying to build a simple Hello World GDK program for Google Glass. 我正在尝试为Google Glass构建一个简单的Hello World GDK程序。 I've looked up everywhere, but all the samples I could find used "Timeline Manager", which was removed by Google after XE 16.
我到处都在查找,但是我可以找到的所有示例都使用了“时间轴管理器”,该工具在XE 16之后被Google删除了。
What I'm trying to do is to create a live card that shows texts (Hello world!) in the middle. 我想做的是创建一个活卡,在中间显示文本(Hello world!)。 I've tried to modify codes from HERE (HuskyHuskie's answer) and HERE (IsabelHM's answer)
我试图从HERE (HuskyHuskie的答案)和HERE (IsabelHM的答案)修改代码
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 我主要修改的是取出TimelineManager部分并替换
mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
with mLiveCard = new LiveCard(this,LIVE_CARD_ID);
使用
mLiveCard = new LiveCard(this,LIVE_CARD_ID);
Also, I'm relatively new to Android. 另外,我对Android还是比较陌生。 I don't quite understand how R.id.XXXX and R.layout.XXXX are missing from the resource.
我不太了解资源中缺少R.id.XXXX和R.layout.XXXX。 Do you need to define it in Manifest or what else?
您需要在清单中定义它还是其他?
The following is the onStartCommand method: 以下是onStartCommand方法:
@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;
}
I strongly recommend using our official samples available on GitHub and reading our documentations as all of those caveats are explained and handled. 我强烈建议使用我们在GitHub上提供的官方示例并阅读我们的文档,因为所有这些警告都得到了解释和处理。
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
. 如果您使用的是最新版本的Android Studio,则还可以通过我们可用的模板
LiveCard
和Immersion
轻松创建一个新项目。
Immersion Activity
or the Simple Live Card
template Immersion Activity
或Simple Live Card
模板
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.