'how to pass intent extras to static shortcuts in android application

i am investigating static shortcuts in a hobby android application

i can get the Google Assistant action tool to work with my application and it passes the feature parameter of the intent action, however i do not understand how to pass intent extra(s) from the static shortcuts displayed on long press of my app icon

here is my shortcuts.xml file contents:-

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <capability android:name="actions.intent.OPEN_APP_FEATURE">
        <intent
            android:targetClass="com.my.app.ui.MainActivity"
            android:data="content://com.my.app/shortcut/new?target=xxadd_titles"
            android:targetPackage="com.my.app">
            <parameter
                android:name="feature"
                android:key="featureParam" />
        </intent>
    </capability>
    <shortcut
        android:enabled="true"
        android:icon="@drawable/ic_baseline_library_add_24"
        android:shortcutDisabledMessage="@string/add_titles"
        android:shortcutId="add_titles_shortcut"
        android:shortcutLongLabel="@string/add_titles"
        android:shortcutShortLabel="@string/add_titles">
        <intent
            android:action="android.intent.action.VIEW"
            android:data="content://com.my.app/shortcut/new?target=add_titles"
            android:targetClass="com.my.app.ui.MainActivity"
            android:targetPackage="com.my.app"/>
        <capability-binding android:key="actions.intent.OPEN_APP_FEATURE">
            <parameter-binding
                android:key="feature"
                android:value="featureParam" />
        </capability-binding>
    </shortcut>

</shortcuts>

my activity receives the data uri however the intent extras are always null when I long press on the app icon and select the static shortcut

however when i use the action tool within Android Studio i receive the intent extras

how do i configure intent extras for static shortcuts

UPDATE When I refactor the shortcuts.xml as follows I can manage to pass extras with my intents

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <capability android:name="actions.intent.OPEN_APP_FEATURE">
        <intent
            android:targetClass="com.my.app.ui.MainActivity"
            android:data="content://com.my.app/shortcut/new?target=xxadd_titles"
            android:targetPackage="com.my.app">
            <parameter
                android:name="feature"
                android:key="featureParam" />
        </intent>
    </capability>
    <shortcut
        android:enabled="true"
        android:icon="@drawable/ic_baseline_library_add_24"
        android:shortcutDisabledMessage="@string/add_titles"
        android:shortcutId="add_titles_shortcut"
        android:shortcutLongLabel="@string/add_titles"
        android:shortcutShortLabel="@string/add_titles">
        <intent
            android:action="android.intent.action.VIEW"
            android:data="content://com.my.app/shortcut/new?target=add_titles"
            android:targetClass="com.my.app.ui.MainActivity"
            android:targetPackage="com.my.app">
            <extra
                android:name="my_action"
                android:value="add_titles" />
        </intent>
        <capability-binding android:key="actions.intent.OPEN_APP_FEATURE">
            <parameter-binding
                android:key="feature"
                android:value="featureParam" />
        </capability-binding>
    </shortcut>

</shortcuts>

however the extra xml tag is highlighted as an error with the message "Element extra is not allowed here"

why is the extra tag not allowed here when the following google docs clearly show that it is?

https://developers.google.com/assistant/app/action-schema



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source