You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google App Action自定义Intent无法在Google Assistant中触发求助

问题

尝试用自定义Intent构建App Actions,通过App Action Test Tool能正常运行Intent并捕获参数,但直接通过Google Assistant交互(比如指令:“Hey Google,打开[应用名称]并12:00制作蛋糕”)时,助手提示“Sorry, I don't understand”。以下是配置文件,需要实现从Google Assistant触发自定义Intent并捕获所有输入参数。

配置文件

shortcuts.xml

<capability
        android:name="custom.actions.intent.MY_CUSTOM_INTENT"
        app:queryPatterns="@array/SampleQueries">
        <intent
            android:action="android.intent.action.VIEW"
            android:targetPackage="com.example.appId"
            android:targetClass="com.example.appId.MainActivity">
            <parameter
                android:name="time"
                android:key="time"
                android:mimeType="https://schema.org/Time" />
        </intent>
</capability>


<shortcut
    android:shortcutId="MY_CUSTOM_INTENT"
    android:shortcutShortLabel="@string/MY_CUSTOM_INTENT">
    <capability-binding android:key="custom.actions.intent.MY_CUSTOM_INTENT">
        <parameter-binding
            android:key="time"
            android:value="@string/my_custom_intent"/>
    </capability-binding>
</shortcut>

strings.xml

<string-array name="SampleQueries">
    <item>make a cake at $time</item>
    <item>make a cake</item>
</string-array>

<string name="my_custom_intent">my_custom_intent</string>

<string name="MY_CUSTOM_INTENT">MY_CUSTOM_INTENT</string>
解决方案
  • 补全中文查询模式:当前SampleQueries只有英文句式,而你使用中文指令,Assistant无法匹配。修改strings.xml的SampleQueries,添加对应中文句式,覆盖实际使用的指令格式:

    <string-array name="SampleQueries">
        <item>make a cake at $time</item>
        <item>make a cake</item>
        <item>在$time制作蛋糕</item>
        <item>打开[你的应用名称]并在$time制作蛋糕</item>
        <item>制作蛋糕</item>
    </string-array>
    

    替换[你的应用名称]为实际应用名称,确保句式和你说出的指令完全匹配。

  • 修正静态快捷方式的参数绑定:当前shortcut配置中,parameter-binding把time参数固定为字符串my_custom_intent,导致Assistant触发静态快捷方式时无法接收动态时间参数。不需要静态快捷方式的话,直接删除整个<shortcut>节点;需要保留的话,移除parameter-binding或设置合理默认值(如"18:00")。

  • 验证Intent参数接收逻辑:确保MainActivity能正确读取time参数,示例代码:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String time = getIntent().getStringExtra("time");
        // 处理time参数的业务逻辑
    }
    
  • 重新推送并索引配置:修改配置后,用App Action Test Tool重新推送最新的shortcuts.xml,然后向Google Assistant发出指令:“Hey Google,重新索引[你的应用名称]”,确保Assistant获取到最新配置。

  • 检查包名与类名正确性:确认targetPackage和targetClass与应用实际包名、MainActivity全类名完全一致,避免路径错误导致Intent无法跳转。

内容的提问来源于stack exchange,提问作者nhat minh dang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 19:55:25