The new flow API for adding shortcuts and widgets in Android 8.0 allows application developers to add shortcuts and widgets from inside the app instead of relying on the widget tray. It also deprecates the old method (sending a broadcast) of adding shortcuts for security reasons.
Launchers need to support this new implementation so that app developers can rely on the system to add their shortcut or widget.
Examples and source
Docs are available in various system class. References include the following:
Publish Pinned shortcut section in header.
Javadoc for ACTION_CREATE_SHORTCUT.
Javadoc for requestPinAppWidget.
Device implementers need to add an activity in their launcher with intent filter actions:
Refer to the API documentation for more details.
This activity should display a confirmation prompt to the user to add the requested widget/shortcut and upon accepting, add the corresponding widget/shortcut on the homescreen.
In case of widgets, the
accept() call should include the widget ID
of the newly added widget.
Implementing a System UI
Partners need to update their Launcher app using the Launcher3 implementation
packages/apps/Launcher3) as reference.
Find the relevant Launcher3 changes in the Android Open Source Project (AOSP):
- Change-Id: 8b2002e28072c52d78f6d052c6ff6da50a2d0324
- Change-Id: 278359539c02ca160caf1df54ce96053a2a2ef59
To validate the feature, try to add shortcuts from Chrome or the Contacts app and verify that a proper confirmation prompt is shown. Upon accepting, the icon should get added on the homescreen and Chrome should display a success toast.