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.