2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
ウィジェットとショートカット
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 8.0 でショートカットとウィジェットを追加するための新しいフロー API を使用することで、アプリ デベロッパーはウィジェット トレイに依存する代わりに、アプリ内からショートカットやウィジェットを追加できます。また、セキュリティ上の理由から、ショートカットを追加する従来のメソッド(ブロードキャストの送信)のサポートも終了します。
ランチャーは、アプリ デベロッパーがシステムを利用してショートカットやウィジェットを追加できるように、この新しい実装をサポートする必要があります。
例とソース
さまざまなシステムクラスでドキュメントを参照できます。リファレンスには次のようなものがあります。
- ShortcutManager.java
ヘッダーで「固定」ショートカット セクションを公開します。
- Intent.java
ACTION_CREATE_SHORTCUT の Javadoc。
- AppWidgetManager.java
requestPinAppWidget の Javadoc。
実装
デバイス実装者は、次のインテント フィルタ アクションを使用して、ランチャーにアクティビティを追加する必要があります。
android.content.pm.action.CONFIRM_PIN_SHORTCUT
android.content.pm.action.CONFIRM_PIN_APPWIDGET
詳細については、API ドキュメントをご覧ください。
このアクティビティは、リクエストされたウィジェット / ショートカットを追加する確認プロンプトをユーザーに表示し、ユーザーが同意した場合、該当のウィジェット / ショートカットをホーム画面に追加します。
ウィジェットの場合、accept()
呼び出しは新しく追加するウィジェットのウィジェット ID を含んでいる必要があります。
システム UI の実装
パートナーは、ランチャー アプリを更新する際に、リファレンスとして Launcher3 実装(packages/apps/Launcher3
)を使用する必要があります。
Android オープンソース プロジェクト(AOSP)で、関連する Launcher3 の変更内容を確認してください。
検証
機能を検証するには、Chrome または連絡帳アプリからショートカットを追加して、適切な確認プロンプトが表示されることを確認します。同意すると、ホーム画面にアイコンが追加され、Chrome に成功トーストが表示されます。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 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."]]