Google Assistant基础「打开我的应用」指令失效及App Actions配置疑问
问题:Google Assistant基础打开应用指令失效
已完成的配置
1. 自定义Intent配置(shortcuts.xml)
<?xml version="1.0" encoding="utf-8"?> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <capability android:name="custom.actions.intent.MOVE_LIFT" app:queryPatterns="@array/ExampleQueries"> <intent android:action="android.intent.action.VIEW" android:targetPackage="my.app.id" android:targetClass="my.app.id.MainActivity"> <parameter android:name="destination" android:key="destination" android:mimeType="https://schema.org/Text" /> </intent> </capability> </shortcuts>
2. 示例查询语句配置(example_queries.xml)
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <string-array name="ExampleQueries"> <item>bring (the)? lift to (the)? $destination</item> <item>call (the)? lift to (the)? $destination</item> <item>open (the)? lift door at (the)? $destination</item> <item>$destination lift door open</item> </string-array> </resources>
3. MainActivity中的Intent处理代码
在onCreate()中添加的代码:
Intent intent = getIntent(); dealWithIncomingIntent(intent);
dealWithIncomingIntent()函数实现:
private void dealWithIncomingIntent(Intent intent) { String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { if (intent.getDataString() != null) { incomingString = intent.getDataString(); } } Log.d("INTENT","Incoming string from intent = '"+incomingString+"'."); }
当前问题
应用UI功能正常,已将签名后的应用包上传至Google Play内部测试轨道并启用App Actions,添加测试用户后安装了应用。根据Android开发者文档,「Hey Google,打开{应用名称}」这类基础指令无需额外配置即可生效,但该指令无法打开我的应用(设备及账号可正常使用Assistant控制其他应用)。已确认Google Play后台与AndroidManifest.xml中的应用名称一致,应用已通过审核且显示名称正确。
疑问
是否需要在AndroidManifest.xml中添加额外配置,或在Gradle构建文件中添加依赖?
内容的提问来源于stack exchange,提问作者Fat Monk
相关产品推荐
相关产品推荐

