Fat Monk
Fat Monk

Reputation: 2265

Google Assistant App Actions - basic 'Hey Google, Open my app' not working

I'm trying to enable Google Assistant voice control of an app I am working on.

I have added a shortcuts.xml file that defines a custom intent as follows:

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <capability
        android:name="custom.actions.intent.MOVE_LIFT"
        app:queryPatterns="@array/ExampleQueries">
        <intent
            android:action="android.intent.action.VIEW"
            android:targetPackage="my.app.id"
            android:targetClass="my.app.id.MainActivity">

        <parameter
            android:name="destination"
            android:key="destination"
            android:mimeType="https://schema.org/Text" />
        </intent>
    </capability>
</shortcuts>

and I have defined exmaple queries for this custom intent in example_queries.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <string-array name="ExampleQueries">
        <item>bring (the)? lift to (the)? $destination</item>
        <item>call (the)? lift to (the)? $destination</item>
        <item>open (the)? lift door at (the)? $destination</item>
        <item>$destination lift door open</item>
    </string-array>

</resources>

I have also added code to my main activity handle the expected incoming intent, but this is a work in progress at the moment. Basically, at the end of onCreate() I call another function with the intent as follows:

Intent intent = getIntent();
dealWithIncomingIntent(intent);

and so far dealWithIncomingItent() looks like this just to check what the intent contains:

private void dealWithIncomingIntent(Intent intent) {
    String action = intent.getAction();
    if (Intent.ACTION_VIEW.equals(action)) {
        if (intent.getDataString() != null) {
            incomingString = intent.getDataString();
        }
    }
    Log.d("INTENT","Incoming string from intent = '"+incomingString+"'.");
}

Outside of Google Assistant voice control the app works as expected, my intention is to use the key:value pair incoming from the intent to trigger some actions within the main activity - actiosn that already work based on button pushes in the app's UI, but I want to automate them with voice.

I have uploaded the signed app bundle to Google Play and published to an internal test track.

I have checked the box in Google Play to enable App Actions for this app.

I have added a couple of users to the internal test track, shared the join test track link, followed the link, installed the app from that link...

The app works as expected via the UI.

I have read somewhere on the Android developer docs that the basic 'Hey Google, open {app name}' should work with just about any app without any of the additional App Actions stuff I have already done, but my app doesn't even open with that command. (This is on a device and with an account that uses Google Assistant all of the time for other stuff using other apps.)

I have checked that the app name in Googel Play matches the app name in the AndroidManifest.xml as I read somewhere that that can sometimes confuse things.

My app has also been reviewed by Google Play - the name displayed is no longer the temporary name assigend while the app is awaiting review, it is the correct app name.

So I am stumped.

I feel like I must have missed something fundamental if even 'Hey Google, open {my app name}' isn't working.

I have been searching for days and just can't find any clues - do I need to add something extra to AndroidManifest.xml? Do I need to add any extra dependencies to the gradle build files?

I feel like I have the detailed stuff in place pretty much to get the voice control working (save for actually calling the functions), but the app is not even opening with 'Hey Google, open {my app name}'...

Upvotes: 0

Views: 55

Answers (0)

Related Questions