Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Widgets and shortcuts
Stay organized with collections
Save and categorize content based on your preferences.
The new flow API for adding shortcuts and widgets in Android 8.0 allows
app 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:
- ShortcutManager.java
Publish Pinned shortcut section in header.
- Intent.java
Javadoc for ACTION_CREATE_SHORTCUT.
- AppWidgetManager.java
Javadoc for requestPinAppWidget.
Implementation
Device implementers need to add an activity in their launcher with intent filter actions:
android.content.pm.action.CONFIRM_PIN_SHORTCUT
android.content.pm.action.CONFIRM_PIN_APPWIDGET
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):
Validation
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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-09-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-23 UTC."],[],[],null,["# Widgets and shortcuts\n\nThe new flow API for adding shortcuts and widgets in Android 8.0 allows\napp developers to add shortcuts and widgets from inside the app instead\nof relying on the widget tray. It also deprecates the old method (sending a\nbroadcast) of adding shortcuts for security reasons.\n\n\nLaunchers need to support this new implementation so that app developers can\nrely on the system to add their shortcut or widget.\n\nExamples and source\n-------------------\n\n\nDocs are available in various system class. References include the following:\n\n- **[ShortcutManager.java](https://developer.android.com/reference/android/content/pm/ShortcutManager.html)** \n Publish Pinned shortcut section in header.\n- **Intent.java** \n Javadoc for ACTION_CREATE_SHORTCUT.\n- **AppWidgetManager.java** \n Javadoc for requestPinAppWidget.\n\nImplementation\n--------------\n\n\nDevice implementers need to add an activity in their launcher with intent filter actions:\n\n- `android.content.pm.action.CONFIRM_PIN_SHORTCUT`\n- `android.content.pm.action.CONFIRM_PIN_APPWIDGET`\n\n\nRefer to the [API\ndocumentation](https://developer.android.com/reference/android/content/pm/LauncherApps.html) for more details.\n\n\nThis activity should display a confirmation prompt to the user to add the [requested\nwidget/shortcut](https://developer.android.com/reference/android/content/pm/LauncherApps.html) and upon accepting, add the corresponding widget/shortcut on\nthe homescreen.\n\n\nIn case of widgets, the `accept()` call should include the widget ID\nof the newly added widget.\n\n### Implementing a System UI\n\n\nPartners need to update their Launcher app using the Launcher3 implementation\n(`packages/apps/Launcher3`) as reference.\n\n\nFind the relevant Launcher3 changes in the Android Open Source Project (AOSP):\n\n- Change-Id: [8b2002e28072c52d78f6d052c6ff6da50a2d0324](https://android.googlesource.com/platform/packages/apps/Launcher3/+/8b2002e28072c52d78f6d052c6ff6da50a2d0324)\n- Change-Id: [278359539c02ca160caf1df54ce96053a2a2ef59](https://android.googlesource.com/platform/packages/apps/Launcher3/+/278359539c02ca160caf1df54ce96053a2a2ef59)\n\nValidation\n----------\n\n\nTo validate the feature, try to add shortcuts from Chrome or the Contacts app\nand verify that a proper confirmation prompt is shown. Upon accepting, the icon\nshould get added on the homescreen and Chrome should display a success toast."]]