GDK:提示语音提示

时间:2013-12-01 15:08:24

标签: google-glass google-gdk

是否可以使用语音触发器的输入提示为用户提供“提示”?这类似于显示“拨打电话”的操作,为您提供可能的选项列表。

例如使用以下内容......

<trigger keyword="@string/start_scan" >

    <constraints
        camera="true"
        network="true" />

    <input prompt="@string/prompt_scan_what" />

</trigger>

我希望用户流程如下......

------------
"Ok, Glass"
------------
"Scan"
------------
What would you like to scan?
QR Code
Product
Barcode
------------
"Barcode"

2 个答案:

答案 0 :(得分:1)

找到一个有一些缺点的解决方法:

  1. 根据选项的数量,使AndroidManifest膨胀。
  2. 获取所选选项的不同方法。
  3. 无法以编程方式完成。
  4. 工作流更像是......

    ---------
    "Ok, Glass"
    ---------
    "Scan"
    ---------
    ok glass, scan...
    QR Code
    Product
    Barcode
    ---------
    "Barcode"
    
  5. Android Manifest:

        <activity android:name="com.cantilsoftware.barcodeeye.LaunchActivity">
        </activity>
    
        <activity-alias
            android:name="Product"
            android:label="Product"
            android:targetActivity="com.cantilsoftware.barcodeeye.LaunchActivity" >
            <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_scan" />
        </activity-alias>
        <activity-alias
            android:name="Barcode"
            android:label="Barcode"
            android:targetActivity="com.cantilsoftware.barcodeeye.LaunchActivity" >
            <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_scan" />
        </activity-alias>
        <activity-alias
            android:name="QR Code"
            android:label="QR Code"
            android:targetActivity="com.cantilsoftware.barcodeeye.LaunchActivity" >
            <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_scan" />
        </activity-alias>
    

    选择检测:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);
    
        try {
            ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), 0);
            processVoiceAction(activityInfo.loadLabel(getPackageManager()).toString());
        } catch (NameNotFoundException e) {
            e.printStackTrace();
            processVoiceAction(null);
        }
    }
    

答案 1 :(得分:0)

您是否尝试在提示文字中的问号后添加换行符(即'/ n')以获得新的新行?