How to integrate classic App Shortcuts with Google Assistant through the new Capabilities API
Assistant Shortcuts (App Actions)
In this example, we will review the use of the classic Android ** Shortcuts ** repowered with ** Google Assistant **, making use of the new ** Capabilities API ** announced in the last Google I / O.
The project is separated into progressive branches, so that you can review the differences between them when you learn a new concept.
The order would be:
- [main] (https://github.com/Tohure/AssistantShortcuts): Base branch with a simple project of 3 screens (Fragments) joined with Jetpack Navigation.
Jetpack Navigation: https://developer.android.com/guide/navigation
- [ShortcutClassic] (https://github.com/Tohure/AssistantShortcuts/tree/ShortcutClassic): Branch where we implement ** Shortcuts **, the Android technology that allows "Direct Access" from the launcher (desktop) of our phone by pressing and holding the icons and displaying them.
Shortcuts: https://developer.android.com/guide/topics/ui/shortcuts
- [ShortcutCapabilities] (https://github.com/Tohure/AssistantShortcuts/tree/ShortcutCapabilities): Branch where the classic Android ** Shortcuts ** and voice actions ** App Actions ** are integrated with the new ** API Capabilities ** announced in recent * Google I / O 21 *.
Capabilities: https://developer.android.com/guide/topics/ui/shortcuts/adding-capabilities
App Actions: https://developers.google.com/assistant/app/overview
- [CapabilitiesInAppPromo] (https://github.com/Tohure/AssistantShortcuts/tree/CapabilitiesInAppPromo): Branch where we will use ** In-App Promo SDK ** to make suggestions directly in the application of the use or call of a specific flow with Google Assistant.
In-App Promo SDK: https://developers.google.com/assistant/app/in-app-promo-sdk
- [WidgetCapabilities] (https://github.com/Tohure/AssistantShortcuts/tree/WidgetCapabilities): Branch where we will use ** Capabilities API ** to invoke Android Widgets, directly in our Google Assistant.
Requirements
- Android Studio 4.2. *
- Android SDK 25>
- Kotlin 1.4. *>
- Google Assistant Plugin for Android Studio ([LINK] (https://plugins.jetbrains.com/plugin/16739-google-assistant))
- Google Play Developers account (Just to launch an Internal Testing and Android can associate the ID of the application with the Google Assistant of your * phone || emulator *.
- Log in with the same Gmail account from the Google Play Developers console, on the * phone || emulator * and on Android Studio so that the Google Assistant plugin works correctly.
Disclaimer
- The project is thinking to work from Android 7.1 (Nougat | Api 25) because ** Shortcuts ** are a technology that just appeared in this version of Android and the new ** Capabilities API ** work with ** Shortcuts **, however you can install it on devices with Android 5 (Lollipop | Api 21) taking into account that neither the Shortcuts nor the capabilities will work.
- To be able to test either on a device or emulator, remember to use the same Gmail account, both in Google Play Developers, in Android Studio and on your phone.