1
votes

I have downloaded this basic example from google: https://github.com/actions-on-google/appactions-fitness-kotlin

Now if I do:

adb shell am start -a android.intent.action.VIEW -d "https://fit-actions.firebaseapp.com/start"

It will start my app. And the deeplink is being recognized. The example shows that I can do this by saying in Google Assistant:

Start running in fit actions

Now I do this, but this only gives me Google search responses, it does not start my app similar to the adb shell command. I did change the package name, so that it complies with my google-services.json file.

What am I doing wrong?

This is what I have in my Manifest:

  <activity
        android:name=".activity.MainActivity"
        android:configChanges="orientation"
        android:exported="true"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize|stateUnchanged">
        <!-- Required to support search action intents from Google Search -->
        <intent-filter>
            <action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>

            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>

        <!-- Define your supported deeplinks -->
        <intent-filter
            android:autoVerify="true">
            <action android:name="android.intent.action.VIEW"/>

            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>

            <data
                android:host="com.package.android"
                android:scheme="https"/>
        </intent-filter>
    </activity>

This is my actions.xml

 <?xml version="1.0" encoding="utf-8"?><!--

<actions>

<!-- This file describes the supported actions by this app -->

<action intentName="actions.intent.START_EXERCISE">

    <!-- Each action requires at least one fulfillment that defines how the app will handle this action -->
    <!-- Define the urlTemplate in the format you define your deeplinks in AndroidManifest.xml -->

    <fulfillment urlTemplate="https://com.package.android/start{?exerciseType}">

        <!-- Define how the actions parameters (intentParameter) is mapped in the urlTemplate above -->

        <parameter-mapping
            intentParameter="exercise.name"
            urlParameter="exerciseType"/>

    </fulfillment>

    <!-- We can define our custom inline inventory, mapping a parameter to an entity set reference -->

    <parameter name="exercise.name">
        <entity-set-reference entitySetId="ExerciseEntitySet"/>
    </parameter>

</action>

<action intentName="actions.intent.STOP_EXERCISE">
    <fulfillment urlTemplate="https://com.package.android/stop"/>
</action>

<action intentName="actions.intent.GET_EXERCISE_OBSERVATION">

    <!-- You can define the fulfillment mode, it can be SLICE or DEEPLINK -->
    <!-- When slice is used, make sure you are supporting slices in your app -->
    <!-- Also, not that the urlTemplate must be of the style content://{slice_provider_authority}/... -->

    <fulfillment
        fulfillmentMode="actions.fulfillment.SLICE"
        urlTemplate="content://com.package.android.FitSliceProvider/stats{?exerciseType}">

        <!-- If a parameter is set as required, the action will only be fulfilled if the parameter is found -->
        <!-- That's why a fallback urlTemplate needs to be provided for such case. -->

        <parameter-mapping
            entityMatchRequired="true"
            intentParameter="exerciseObservation.aboutExercise.name"
            required="true"
            urlParameter="exerciseType"/>

        <!-- Note, that for the parameter above we are setting entityMatchRequired="true" -->
        <!-- This tells the Assistant to only use the entity set values to map this parameter -->
        <!-- Meaning that even if the assistant know how to identify the exercise (i.e "Climbing") -->
        <!-- if it's not defined in our entity set, the parameter won't be use. -->

    </fulfillment>

    <!-- In case the exercise name is not found we fallback to the stats deep-link inside the app -->

    <fulfillment
        fulfillmentMode="actions.fulfillment.DEEPLINK"
        urlTemplate="https://com.package.android/stats"/>

    <!-- Same as the first action, we map the parameter name with out supported entity set. -->

    <parameter name="exerciseObservation.aboutExercise.name">
        <entity-set-reference entitySetId="ExerciseEntitySet"/>
    </parameter>

</action>

<!-- Defines an entity set with our supported entities -->

<entity-set entitySetId="ExerciseEntitySet">

    <!-- For each entity you can specify the name, alternate names and the identifier -->
    <!-- The identifier is the value that will be added to the action uri. -->
    <!-- For our sample we map the supported entities with the class FitActivity.Type  -->

    <entity
        name="@string/activity_running"
        alternateName="@array/runningSynonyms"
        identifier="RUNNING"/>
    <entity
        name="@string/activity_walking"
        alternateName="@array/walkingSynonyms"
        identifier="WALKING"/>
    <entity
        name="@string/activity_cycling"
        alternateName="@array/cyclingSynonyms"
        identifier="CYCLING"/>
</entity-set>

If I try App Actions Test Tool v2.00 it doesn't find the app. The exercise also always goes back to this format with http://schema.googleapis.com

enter image description here

EDIT:

After setting actions like this:

<actions>
<action intentName="actions.intent.OPEN_APP_FEATURE">
    <fulfillment urlTemplate="https://www.xelion.com/start{?feature}">
        <parameter-mapping
            intentParameter="featureType"
            urlParameter="feature"/>
    </fulfillment>

    <parameter name="featureType">
        <entity-set-reference entitySetId="EntitySet"/>
    </parameter>
</action>

<entity-set entitySetId="EntitySet">

    <!-- For each entity you can specify the name, alternate names and the identifier -->
    <!-- The identifier is the value that will be added to the action uri. -->
    <!-- For our sample we map the supported entities with the class FitActivity.Type  -->
    <entity
        name="@string/action_call"
        alternateName="@array/callSynopsis"
        identifier="CALL"/>

</entity-set>

I get this when pressing on update preview in App Action Test Tool:

App Actions Test Tool v2.0.0
        Preview Creation Error
        Status Code: 400
        Message: Precondition check failed.
        - Parameter name 'featureType' is invalid for intent 'actions.intent.OPEN_APP_FEATURE.'
        - Parameter name 'featureType' is invalid for intent 'actions.intent.OPEN_APP_FEATURE.'

Any ideea why?

1

1 Answers

2
votes

You need to first trigger the action using the App Actions Test Plugin: https://plugins.jetbrains.com/plugin/12322-app-actions-test-tool

Once you've installed the plugin, you'll find it under 'Tools' and you can define an invocation name for your app + parameters.

From then on, you can trigger it using "Ok Google".