我有问题根据此tutorial为Google Glass创建基本应用程序。我有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清单
<?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>
有人知道我错过了什么吗?我试图运行它,但我找不到它。
答案 0 :(得分:1)
编辑:
添加权限后,语音命令工作正常,但应用程序崩溃,因为清单中的包名称错误。
See the whole update project on my GitHub.
The tutorial使用自定义语音命令。您需要在清单中使用此权限:
<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
你能试试这个清单吗?
<?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>