gpt4 book ai didi

java - 谷歌眼镜中的 Hello World

转载 作者:行者123 更新时间:2023-12-01 12:33:24 25 4
gpt4 key购买 nike

我在基于此tutorial为谷歌眼镜创建基本应用程序时遇到问题。我有2节课。我完全按照教程进行操作,但我在谷歌眼镜中找不到它。我从“Ok Glass”尝试过,但也找不到。我创建了2个类,第一个是HelloWorldActivity.java。该类是一个 Activity 类。这是HelloWorldActivity.java

public class HelloWorldActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Card myCard = new Card(this);
myCard.setText("Hello, World!");
myCard.setFootnote("First Glassware for Glass");
View cardView = myCard.getView();
// Display the card we just created
setContentView(cardView);
}


}

第二个是HelloGlass.java,这个类是一个Service类,可以识别语音命令。

public class HelloGlass extends Service {

@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}

public int onStartCommand(Intent intent, int flags, int startId) {

Intent i = new Intent(this, HelloWorldActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
return START_STICKY;
}
}

我已经创建了必要的 xml 文件,包括 voice_trigger_start.xml。这是 andorid list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.helloglass"
android:versionCode="1"
android:versionName="1.0" >

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

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HelloWorldActivity"
android:label="@string/app_name"
android:enabled="true" >
</activity>
<service
android:name="com.app.helloglass.HelloGlass"
android:enabled="true"
android:exported="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<!-- Voice command found in res/xml/voice_trigger_start -->
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/voice_trigger_start" />
</service>
</application>

</manifest>

有人知道我错过了什么吗?我尝试运行它,但找不到它。

最佳答案

编辑:

添加权限后,语音命令正常,但应用程序崩溃,因为 list 中的包名称错误。

See the whole update project on my GitHub.

The tutorial使用自定义语音命令。您需要在 list 中获得此权限:

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

请参阅Why is my voice command missing from the ok glass menu in XE16?还有https://developers.google.com/glass/develop/gdk/voice

您可以尝试一下这个 list 吗:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.helloglass"
android:versionCode="1"
android:versionName="1.0" >

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

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

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HelloWorldActivity"
android:label="@string/app_name"
android:enabled="true" >
</activity>
<service
android:name="com.app.helloglass.HelloGlass"
android:enabled="true"
android:exported="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<!-- Voice command found in res/xml/voice_trigger_start -->
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/voice_trigger_start" />
</service>
</application>

</manifest>

关于java - 谷歌眼镜中的 Hello World ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25763731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com