具有自定义查询模式的Android应用程序操作
我有一个android应用程序,它使用com.google.android.gms.actions.SEARCH\u ACTION 要在我的应用程序上搜索短语,请使用app_NAME上的搜索短语,但现在我想使用app_NAME phrase之类的自定义语音命令打开我的应用程序,并使用谷歌助手传递该短语。 那么有可能实现这个功能吗 我试图深入了解行动意图的实际工作原理,并发现使用深度链接是可能的 在actions.xml文件的这个示例中,一个action actions.intent.GET_EXERCISE_OBSERVATION实现了如下代码所示具有自定义查询模式的Android应用程序操作,android,actions-on-google,app-actions,Android,Actions On Google,App Actions,我有一个android应用程序,它使用com.google.android.gms.actions.SEARCH\u ACTION 要在我的应用程序上搜索短语,请使用app_NAME上的搜索短语,但现在我想使用app_NAME phrase之类的自定义语音命令打开我的应用程序,并使用谷歌助手传递该短语。 那么有可能实现这个功能吗 我试图深入了解行动意图的实际工作原理,并发现使用深度链接是可能的 在actions.xml文件的这个示例中,一个action actions.intent.GET_EX
<action intentName="actions.intent.GET_EXERCISE_OBSERVATION">
<fulfillment
fulfillmentMode="actions.fulfillment.SLICE"
urlTemplate="content://com.devrel.android.fitactions.FitSliceProvider/stats{?exerciseType}">
<parameter-mapping
entityMatchRequired="true"
intentParameter="exerciseObservation.aboutExercise.name"
required="true"
urlParameter="exerciseType" />
</fulfillment>
<fulfillment
fulfillmentMode="actions.fulfillment.DEEPLINK"
urlTemplate="https://fit-actions.firebaseapp.com/stats" />
<parameter name="exerciseObservation.aboutExercise.name">
<entity-set-reference entitySetId="ExerciseEntitySet" />
</parameter>
</action>
<!-- Defines an entity set with our supported entities -->
<entity-set entitySetId="ExerciseEntitySet">
<entity
name="@string/activity_running"
alternateName="@array/runningSynonyms"
identifier="RUNNING" />
<entity
name="@string/activity_walking"
alternateName="@array/walkingSynonyms"
identifier="WALKING" />
<entity
name="@string/activity_cycling"
alternateName="@array/cyclingSynonyms"
identifier="CYCLING" />
</entity-set>
但是现在我有一些关于这个代码的问题
content://com.devrel.android.fitactions.FitSliceProvider/stats{?exerciseType}
是否生成actions.fulfillment.SLICEhttps://fit-actions.firebaseapp.com/stats
是否生成actions.fulfillment.DEEPLINKactions.intent.OPEN_APP_功能
将在DEEPLINK实现的帮助下有所帮助
那么,是否可以使用actions.intent.OPEN_APP_功能来实现这一点呢
content://com.devrel.android.fitactions.FitSliceProvider/stats{?exerciseType}
是否生成了actions.fulfillment.SLICEurlTemplate
值(无论是通过slice还是deep-link实现)完全由您定义。对于deep-link,这是系统将调用以打开应用程序的URL。对于slice,这是系统将调用以呈现slice的contentUri。{}将在运行时用值展开。要更好地了解其工作原理,请参阅文档和或
exerciseObservation.aboutExercise.name的参数name是为每个助手设置的,不能更改。这些值列在文档()中。参数的实际值(在运行时由用户的查询填充)是动态的,并将根据用户的查询和助手意图而更改。对于每个助手意图,您可以参考文档以查看可能的值。在某些情况下,它们来自一组值(如For),对于其他用户,它可以是基于用户输入的自由形式值,对于其他用户,您仍然可以选择使用扩展值(这就是您在示例中使用的
)
如何使用URL模板https://fit-actions.firebaseapp.com/stats
用于
是否生成actions.fulfillment.DEEPLINK
根据#1,urlTemplate
的值完全由您来配置。它可以是任何Android意向URI。系统将调用此URI来启动您的应用程序/活动
我想在实施了这个之后
actions.intent.OPEN\u APP\u功能将有助于
帮助DEEPLINK实现
那么,是否可以使用
动作。意图。打开应用程序功能“
OPEN\u APP\u FEATURE
只是另一个助手意图,它允许对应用程序的某个功能进行一般调用。最近更新了一些示例查询。例如
打开Youtube历史记录
此示例将打开名为“YouTube”的应用程序,并将功能名称“history”传递给要处理的应用程序
打开示例应用程序示例功能
此示例将打开名为“示例应用程序”的应用程序,并将功能名称“示例功能”传递给要处理的应用程序。请检查此链接