0

I have problem create a basic applicationn for google glass based on this tutorial. I have 2 classes. I followed exactly the same as the tutorial, but I couldn't find it in google glass. I tried from "Ok Glass", but I also couldnt find it. I have created 2 classes, the first is HelloWorldActivity.java. This class is a Activity class. Here is the 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);
}


}

The second is HelloGlass.java This class is a Service class that will recognize the voice command.

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;
   } 
}

I have created the necessary xml files including the voice_trigger_start.xml. Here is the andorid manifest

<?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>

Anybody know what I have missed? I tried to run it but I couldn't find it.

eng
  • 83
  • 1
  • 8

1 Answers1

1

Edit:

After adding the permission, the voice command works fine but the app crashes because the package name in the manifest is wrong.

See the whole update project on my GitHub.

The tutorial uses a custom voice command. You need this permission in the manifest:

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

Please see Why is my voice command missing from the ok glass menu in XE16? and also https://developers.google.com/glass/develop/gdk/voice

Could you try this manifest:

<?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>
Community
  • 1
  • 1
pt2121
  • 11,060
  • 7
  • 50
  • 68
  • Hi, I found the answwer. FIrst of all,there's someonle also create the application for the hello glass (https://github.com/DasCody/Hello-Glass). As I remember, they use the timeLineManager, but because timeLinemanager isn't exist anymore, I have to change it to LiveCard – eng Sep 12 '14 at 06:56
  • 1
    Glad you found the answer. If you're still curious what wrong with the tutorial, you can check https://github.com/prt2121/HelloGlass. I just got it working. – pt2121 Sep 12 '14 at 13:16
  • @EntryLevelDev Hi, I hope you don't mind me asking but I'm trying to piece together a Glass project and am an Android novice. We got a few pairs of Glass at work and I'd like to get something up. I'm trying to have a voice trigger start up a menu, ideally "ok glass" styled, and then from any of the choices it would start another activity which is a video player. Could I have some advice on where I'm going wrong? I have panel menu working and videoplayer activity working, but separate from each other and its a bit of a mess now. Any advice is appreciated! https://github.com/tetreault/HelloGlass – Stephen Tetreault Sep 29 '14 at 20:16
  • @SMT I will check your issues when I have a chance. – pt2121 Sep 29 '14 at 23:12
  • 1
    @EntryLevelDev Hey, I saw what you did on gitr I will take a look soon today. Thank you again for the assistance! – Stephen Tetreault Oct 01 '14 at 13:21