Voice Capabilities in Android Wear

爱⌒轻易说出口 提交于 2019-12-09 06:52:43

问题


I am trying to add Voice Capabilities in Android Wear and following below URL

https://developer.android.com/training/wearables/apps/voice.html

Here is my manifest

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

    <uses-feature android:name="android.hardware.type.watch" />

    <uses-permission android:name="android.permission.VIBRATE" />

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

    <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>
        <activity
            android:name=".TaxiActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.google.android.gms.actions.RESERVE_TAXI_RESERVATION" />
            </intent-filter>
        </activity>
    </application>

</manifest>

But when i am trying below voice commands in my LG G watch it doesn't open my activity...it just showing Google search results

"OK Google, get me a taxi"

"OK Google, call me a car"

Thanks.


回答1:


The wearable doesn't know this is a wear app. Wear apps need this in their manifest: <uses-feature android:name="android.hardware.type.watch" />




回答2:


Had the same problem. The solution was to add the category android.intent.category.DEFAULT to the intent filter:

    <activity android:name=".TaxiActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="com.google.android.gms.actions.RESERVE_TAXI_RESERVATION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

If you open the Android Wear app on the phone you can verify that your app is available under "Call a car" beneath "Voice actions".

For non-English speakers still having problems using the voice command you should double check the language used for voice commands on your device. Change it to English and try it out. If that still doesn't work you can try changing the device's language to English also.



来源:https://stackoverflow.com/questions/25928594/voice-capabilities-in-android-wear

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!