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.
Relevant Launcher3 changes:
- Change-Id: I664366822fe8088742faff2cce006239ab0771bc
- Change-Id: I905532ba44a8898c9c17476f9f75bc309eeb7b41
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.