How to trigger widget with custom intent?

37 views Asked by At

I'm trying to trigger my widget with custom intents using google assistant prompt, but the widget didn't show up even after i pass an exact query, Something like "Get Balance on MyApp".

  • The Widget showing correctly when i tried to use Google App Action Tools and run the custom intent preview.
  • This problem not occur when i'm using a Common BII for my shortcut.xml capability.

Here's my Shortcut.xml

<capability
        android:name="custom.actions.intent.GET_BALANCE"
        app:queryPatterns="@array/GetBalanceQueries">
        <app-widget
            android:targetClass="com.mypackagename.bankapp.widget.BalanceWidgetProvider"
            android:targetPackage="com.mypackagename.bankapp">

            <extra
                android:name="hasTts"
                android:value="true" />
        </app-widget>
        
        <intent
            android:action="android.intent.action.VIEW"
            android:targetClass="com.mypackagename.widget.BalanceWidgetProvider">
        </intent>
</capability>

Manifest

<!--widget-->
        <receiver
            android:name=".ui.widget.BalanceWidgetProvider"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/balance_widget" />
        </receiver>
        <service
            android:name=".ui.widget.BalanceWidgetProvider"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.assistant.appactions.widgets.PIN_APP_WIDGET" />
            </intent-filter>
        </service>

Dependency

implementation 'com.google.assistant.appactions:widgets:0.0.1'

Sample Query

<string-array name="GetBalanceQueries">
        <item>get account balance</item>
        <item>get balance</item>
        <item>get portfolio</item>
        <item>check balance</item>
        <item>check portfolio</item>
        <item>show balance</item>
        <item>show portfolio</item>
        <item>show my money</item>
        <item>show money</item>
        <item>show money report</item>
        <item>show funds</item>
        <item>show fund report</item>
        <item>show portfolio</item>
    </string-array>
0

There are 0 answers