1

I have the actions xml referenced in my manifest as well as my slice provider

<application>
  <meta-data
    android:name="com.google.android.actions"
    android:resource="@xml/actions" />


<provider
      android:name=".sliceproviders.MyAppSliceProvider"
      android:authorities="com.company.app"
      android:exported="true"
      android:grantUriPermissions="true">
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.app.slice.category.SLICE" />
      </intent-filter>
    </provider>

</application>

My actions xml references my slice uris and my query patterns

<actions>
  <action
    intentName="custom.actions.intent.UNIT_STATUS"
    queryPatterns="@array/UnitStatusQueries">
    <fulfillment
      fulfillmentMode="actions.fulfillment.SLICE"
      urlTemplate="content://com.company.app/unit_status" />
  </action>
</actions>

When hovering over the UnitStatusQueries, I see the values in my string array

  <string-array name="UnitStatusQueries">
    <item>View unit status</item>
    <item>What is the status of my unit?</item>
    <item>Is my unit open?</item>
  </string-array>

I have granted assistant permissions

 @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    private fun grantAssistantPermissions() {
        getAssistantPackage()?.let { assistantPackage ->
            val sliceProviderUri = Uri.Builder()
                .scheme(ContentResolver.SCHEME_CONTENT)
                .authority("com.company.app")
                .build()
            androidx.slice.SliceManager.getInstance(this)
                .grantSlicePermission(assistantPackage, sliceProviderUri)
        }
    }


    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    private fun getAssistantPackage(): String? {
        val resolveInfoList = packageManager?.queryIntentServices(
            Intent(VoiceInteractionService.SERVICE_INTERFACE), 0
        )
        return resolveInfoList?.firstOrNull()?.serviceInfo?.packageName
    }

I am confident my slice provider works since running the Google Assistant test tool and the App Actions test tool correctly shows the slices in Google Assistant.

The final piece of the puzzle is actually getting Google Assistant to recognize the query and show my slice (outside of the test tools). I have deployed several builds for internal testing but nothing seems to work. Every time I try to use one of these invocation phrases I just get search results or the app opens. I have tried combinations of: "Hey google, open [my app] and view unit status" "Hey google, view unit status" "Hey google, is my unit open?"

Any insight would be greatly appreciated.

Sean Calkins
  • 312
  • 2
  • 11
  • Just adding an update. All actions work with the test tools and work with with google assistant via voice commands. When the app is downloaded from the store, or if my preview is deleted, google assistant no longer recognizes the invocation phrase. – Sean Calkins Jan 24 '22 at 18:26
  • Where did you locate your UnitStatusQueries? i'm trying to use custom intent, but seems that google not recognize any of my string-array combination. – Bruse Feb 07 '22 at 11:53
  • I have them in my string files. The issues seems to be that without generating a preview, Google Assistant cannot recognize the custom intent invocation phrases until the app is live. @Bruse – Sean Calkins Feb 08 '22 at 21:09

1 Answers1

0

I think there was just a misunderstanding on my end as to how the testing of Google Assistant and Slices are supported. Based on this link below I have determined my code is working correctly and the app actions will not be testable (outside of the app actions test tool) until the app is deployed. https://github.com/actions-on-google/appactions-fitness-kotlin/issues/8

One thing that was causing confusion for me was the invocation name I used when creating my app preview. I didn't put in my full app name when creating the preview, which made it so when I used the full app name with Google Assistant, my queries were not recognized.

Sean Calkins
  • 312
  • 2
  • 11