[英]How do I set up assistant shortcut suggestions with actions.intent.OPEN_APP_FEATURE?
So I'm just wondering why my code isn't working.所以我只是想知道为什么我的代码不起作用。 How do I give AppShorcutIntent a specific intent with an action and data and stuff like that?
如何给 AppShorcutIntent 一个带有动作和数据之类的特定意图?
This is my code so far:到目前为止,这是我的代码:
val appShortcutIntent = AppShortcutIntent.builder()
.setIntentName("actions.intent.OPEN_APP_FEATURE")
.setPackageName("com.app.name")
.setIntentParamName("feature")
.setIntentParamValue("")
.build()
shortcutsClient.lookupShortcut(appShortcutIntent)
.addOnSuccessListener { shortcutLookupResult ->
if (shortcutLookupResult.isShortcutPresent) {
shortcutsClient.createShortcutSettingsIntent().addOnSuccessListener { intent ->
requireActivity().startActivity(intent)
}
return@addOnSuccessListener
}
val signalShortcut = AppShortcutSuggestion.builder()
.setAppShortcutIntent(appShortcutIntent)
.setCommand("feature on")
.build()
shortcutsClient.createShortcutSuggestionIntent(signalShortcut).addOnSuccessListener { intent ->
requireActivity().startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
}
}
I have tried so many different things and none of it seems to want to work the way I want.我尝试了很多不同的东西,但似乎都不想按照我想要的方式工作。 I know the question doesn't have anything specific as the parameter value but no matter what I set the param value too it still just doesn't get recognized as a unique intent when I use the shortcut.
我知道这个问题没有任何具体的参数值,但无论我设置什么参数值,当我使用快捷方式时,它仍然没有被识别为独特的意图。
The in-app promo library API doesn't deal with Android intents.应用内促销库 API 不处理 Android 意图。 It deals with Assistant's built-in intents , which are an entirely different things (even though they are both called "intents").
它处理 Assistant 的内置意图,这是完全不同的事情(尽管它们都被称为“意图”)。 In the example you copied, it refers to the BII called OPEN_APP_FEATURE .
在您复制的示例中,它指的是名为OPEN_APP_FEATURE的 BII。
By using this API, you are telling Assistant how to create a shortcut that launches the app using a BII that it is already configured to handle.通过使用此 API,您将告诉 Assistant 如何创建一个快捷方式,该快捷方式使用已配置为处理的 BII 启动应用程序。 This BII is important because it carries the ability to recognize natural language queries associated with it.
这个 BII 很重要,因为它具有识别与之相关的自然语言查询的能力。 Android intents don't have that context.
Android 意图没有该上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.