首页 > 解决方案 > 谷歌助手未在 Android 应用上采用新的 URI

问题描述

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

动作.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 助理语音命令:“打开 [我的应用名称] 速度测试”然后它只是打开应用“打开 [我的应用名称] 支持”然后它打开意图过滤器定义的预期活动

Uri String - myappname://speed test/open?appFeature=support on give voice command "Open [myappname] [support]" 但是当我将语音命令设为 Open [myappname] [speed test] 时,它会启动应用程序。应用内操作测试工具可以工作,但不能与谷歌助手一起使用,既不是语音也不是文本。

标签: androidactions-on-googleapp-actions

解决方案


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


推荐阅读