简体   繁体   English

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

[英]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.

相关问题 在 Android 上,我无法让 actions.intent.OPEN_APP_FEATURE 在应用程序操作测试工具之外工作 - On Android, I cannot get actions.intent.OPEN_APP_FEATURE to work outside the App Actions Test Tool 如何将 URL 参数添加到 {@url} for actions.intent.OPEN_APP_FEATURE? - How to add a URL parameter to {@url} for actions.intent.OPEN_APP_FEATURE? 如何更改“功能”以从 OPEN_FEATURE 的应用操作中打开? - How To change “Feature” to open from App actions for OPEN_FEATURE? 如何在主屏幕上设置快捷方式的启动方式? Android的 - How can I set up the launch intent for shortcut on home screen? Android Android 如何设置 Intent 以打开 adobe connect 应用程序 - Android how can I set an Intent to open adobe connect app 如何让谷歌助手识别我的自定义意图? - How do I get google assistant to recognize my custom intent? 如何使用Android从Intent打开Paytm应用? - How do I open Paytm app from Intent using Android? Android - 如何通过Intent在另一个应用程序中打开文件? - Android - How do I open a file in another app via Intent? 如何使用 Google Assistant 测试 App Actions? - How to test App Actions using Google Assistant? 如何将数据添加到应用程序快捷方式 Intent - How to add data to app shortcut Intent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM