为什么我无法创建要求2个文本的自定义意图?

问题描述

我有一个自定义的意图,就是要从Google助手接收2个文本参数。但是助手不会启动我的应用程序。我只尝试了一种,它可以正常工作。问题是当我添加第二个文本参数时。我尝试了另一种数据类型,它可以工作。例如,如果我要求输入文本和数字,则效果很好。如果我要求提供文本和时间,也可以。但是,如果我要一个文本和一个文本,那么它不是。请帮忙吗? 这是我在actions.xml文件中的意图:

<action intentName="custom.actions.intent.MyName" queryPatterns="@array/MyExampleStrings">
   <!-- Define parameters -->
   <parameter name="textA" type="https://schema.org/Text" />
   <parameter name="textB" type="https://schema.org/Text" />

   <!-- Define fulfillment -->
   <fulfillment urlTemplate="https://my.site.com/{?FirstText,SecondText}">
      <parameter-mapping intentParameter="textA" urlParameter="FirstText" />
      <parameter-mapping intentParameter="textB" urlParameter="SecondText" />
   </fulfillment>
</action>

MyExampleStrings类似于“使用$ textB烘烤$ textA”,例如“烘烤番茄意粉”。

正如我之前说过的,它适用于不同的数据类型。在下一个示例中,我将第二个文本更改为数字,并且可以正常工作:

<action intentName="custom.actions.intent.MyName" queryPatterns="@array/MyExampleStrings">
   <!-- Define parameters -->
   <parameter name="textA" type="https://schema.org/Text" />
   <parameter name="textB" type="https://schema.org/Number" /> <--NUMBER!

   <!-- Define fulfillment -->
   <fulfillment urlTemplate="https://my.site.com/{?FirstText,SecondText}">
      <parameter-mapping intentParameter="textA" urlParameter="FirstText" />
      <parameter-mapping intentParameter="textB" urlParameter="SecondText" />
   </fulfillment>
</action>

在这种情况下,如果我说“用4烤意大利面”之类的话,它会起作用。 为什么我不能有两个字符串??? 谢谢您的帮助

解决方法

我刚刚尝试使用上面的示例来复制问题,但此操作符合我的预期。这两个字段都包含在intent?.data字段中。因此,就我而言,它看起来像这样:

https://todo.myapp.com/custom-intents?FirstText=Example123&SecondText=Example222

您能否进一步详细说明如何检索查询参数?

作为一般建议,活动的onCreate函数中的日志语句应提供以下详细信息:

override fun onCreate(savedInstanceState: Bundle?) {
    Timber.tag(TAG).d("======= debugging data =========" + intent?.data)
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...