如何使用 actions.intent.OPEN_APP_FEATURE 设置助手快捷方式建议?

How do I set up assistant shortcut suggestions with actions.intent.OPEN_APP_FEATURE?

所以我只是想知道为什么我的代码不起作用。我如何为 AppShorcutIntent 提供一个特定的意图,包括一个动作和数据以及类似的东西?

到目前为止,这是我的代码:

            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))
                    }
                }

我尝试了很多不同的东西,其中 none 似乎想要按照我想要的方式工作。我知道这个问题没有任何具体的参数值,但无论我设置的参数值是多少,当我使用快捷方式时,它仍然不会被识别为一个独特的意图。

应用内促销库 API 不处理 Android 意图。它处理 Google 助理的 built-in intents, which are an entirely different things (even though they are both called "intents"). In the example you copied, it refers to the BII called OPEN_APP_FEATURE.

通过使用此 API,您将告诉 Google 助理如何创建一个快捷方式,以使用已配置为处理的 BII 启动应用程序。此 BII 很重要,因为它具有识别与其关联的自然语言查询的能力。 Android 意图没有那个上下文。