Google 助理未在 Android 应用程序上使用新的 URI [英] Google assistant not taking the new URI on Android app

查看:20
本文介绍了Google 助理未在 Android 应用程序上使用新的 URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 App Actions 和 BII(内置意图)集成谷歌助手.问题是当我尝试使用语音命令时,它没有打开预期的屏幕,而只是打开应用程序..当我调试它时,传入的 URI 是不同的(旧的),但我现在有一个不同的.

<块引用>

Actions.Xml

<action intentName="actions.intent.OPEN_APP_FEATURE"><!-- 每个参数都可以使用自定义 ID 引用一个实体集.--><参数名称=特征"><entity-set-reference entitySetId="FeatureEntitySet";/></参数><fulfillment urlTemplate="myappname://speed test/open{?appFeature}"><参数映射意图参数=特征"urlParameter="appFeature"/></履行></动作><entity-set entitySetId="FeatureEntitySet"><实体名称=速度测试"标识符=速度测试";/><!--<实体名称=第二个特征"标识符=特征二";/>--></实体集>

<块引用>

AndroidManifest

<意图过滤器><action android:name="android.intent.action.VIEW";/><category android:name="android.intent.category.DEFAULT"/><category android:name="android.intent.category.BROWSABLE";/><!-- 接受以myappname://speed test"开头的URIs--><数据android:host="速度测试";android:scheme="myappname";/></意图过滤器></活动>

<块引用>

SupportActivity.java

private void handleIntent(Intent intent) {String appLinkAction = intent.getAction();URI appLinkData = intent.getData();if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null) {String appFeature = appLinkData.getQueryParameter(appFeature");if (appFeature != null && appFeature.contains(SPEED TEST")) {//startActivity 或者做点什么}}}

Google 助理语音指令:打开[我的应用程序名称]速度测试"然后它只是打开应用程序打开 [myappname] 支持"然后它打开意图过滤器定义的预期活动

Uri 字符串 - myappname://speed test/open?appFeature=support 提供语音命令打开 [myappname] [support]";但是当我以 Open [myappname] [speed test] 发出语音命令时,它会启动应用程序.应用内操作测试工具可以正常工作,但不能与谷歌助手一起使用,无论是语音还是文本.

解决方案

确保您使用的是 3.4.2+ 应用操作测试工具 (AATT).显示旧 URL 表示预览尚未使用最新的 actions.xml 进行更新.

I'm Integrating the google assistant using App Actions and BII(Built-in Intents). The issue is when I tried with the voice command it's not opening the intended screen rather it just opens the app..when I debugged it incoming URI is different(Old one) but I have a different one now.

Actions.Xml

<actions>
<action intentName="actions.intent.OPEN_APP_FEATURE">
    <!-- Each parameter can reference an entity set using a custom ID. -->
    <parameter name="feature">
        <entity-set-reference entitySetId="FeatureEntitySet" />
    </parameter>

    <fulfillment urlTemplate="myappname://speed test/open{?appFeature}">
        <parameter-mapping
            intentParameter="feature"
            urlParameter="appFeature" />
    </fulfillment>
</action>

<entity-set entitySetId="FeatureEntitySet">
    <entity
        name="speedtest"
        identifier="SPEED TEST" />
    <!--<entity
        name="second feature"
        identifier="FEATURETWO" />-->
</entity-set>

AndroidManifest

<activity
        android:name=".activities.SupportActivity"
        android:launchMode="singleTop"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "myappname://speed test" -->
            <data
                android:host="speed test"
                android:scheme="myappname" />
        </intent-filter>
    </activity>

SupportActivity.java

private void handleIntent(Intent intent) {
    String appLinkAction = intent.getAction();
    Uri appLinkData = intent.getData();

    if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null) {
        String appFeature = appLinkData.getQueryParameter("appFeature");
        if (appFeature != null && appFeature.contains("SPEED TEST")) {
            //startActivity or do something
           
        }
    }
}

Google Assistant Voice Command: "Open [my app name] speed test" then it just opens the app "Open [myappname] support" then it opens the intended activity where the intent filter defined

Uri String - myappname://speed test/open?appFeature=support on giving voice command "Open [myappname] [support]" but when I give voice command as Open [myappname] [speed test] it launches the app. In-App Action Test Tool working but not with google assistant neither voice nor text.

解决方案

Make sure you're using 3.4.2+ App Actions Test Tool (AATT). Showing the old URL is a sign that the preview hasn't been updated with the latest actions.xml.

这篇关于Google 助理未在 Android 应用程序上使用新的 URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆