Jose
Jose

Reputation: 51

Voice command not working on my glass app

My manifest file is as below

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

    <uses-sdk
        android:minSdkVersion="19"
        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"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>



    <service
            android:name="com.demo.myglassapp.MainActivity"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
            </intent-filter>
            <meta-data
                android:name="com.google.android.glass.VoiceTrigger"
                android:resource="@xml/voice_trigger_start" />
        </service>

    </application>

</manifest>

voice trigger start file

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/its_demo" />

My strings.xml file

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">myglassapp</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="its_demo">Hello Sir</string>

</resources>

As per my knowledge I have added a code block

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

in manifest file. I created a voice trigger file and set a variable in it.

Now i call that variable from strings.xml file.

So, basically it is all correct but i do not see "Hello Sir" added to my OK GLASS menu.

When I run my application from Eclipse IDE, i do not see my menu after OK GLASS menu option. In stead, I see my app directly running like it runs in Android phone when we set it in debug mode.

Any idea why it is not working?

Upvotes: 0

Views: 261

Answers (3)

user3542552
user3542552

Reputation: 168

I agree with Nicole. Maybe if you move some stuff around it may work. But, it depends a lot on how you are building your app. In my case, for example, the voice trigger intent is define for my activity, not my service (Similar to Nicole's case). However, I have seen some examples where the trigger is on the service. You can check those examples by creating a sample Android project in Eclipse.

Now, the reason why your app is opening after you run it similarly to a mobile is because you have this on your manifest

       <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

You should remove that if you dont want that behavior

Upvotes: 1

Nicole
Nicole

Reputation: 13

I am new to glassware development.. but maybe try moving some things inside your application tag in manifest (instead of the service tag.. I do not have a service tag at all). Here's an example of my manifest file that works with voice recognition from the start menu...

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

                  <meta-data
            android:name="com.google.android.glass.VoiceTrigger"
            android:resource="@xml/voice_trigger_start" />


    </activity>
</application>`

Upvotes: 0

Anuja
Anuja

Reputation: 32

In your glass itself you say your application name it will show the list of app Try this Hope this will help

Upvotes: 0

Related Questions