ショートカットに関するおすすめの方法
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
アプリのショートカットを設計、作成する際は、次のガイドラインに従ってください。
-
設計ガイドラインを遵守する
-
アプリのショートカットとシステムアプリで使用するショートカットを一致させるには、アプリ ショートカットのアイコンの設計ガイドラインに準拠します。
-
4 つの異なるショートカットのみを公開する
-
API では、最大 15 個の静的ショートカットと動的ショートカットの組み合わせがサポートされていますが、ランチャーでの外観を改善するために、4 つの異なるショートカットのみを公開することをおすすめします。
ランチャーにショートカットを表示するだけでなく、Google Shortcuts Integration Library を使用して、Google アシスタントなどの Google サーフェスにショートカットを表示できます。このライブラリでは、プッシュできる動的ショートカットの数に制限はありません。このライブラリを使用して多数のショートカットをプッシュする場合は、setRank()
メソッドを呼び出して、サポートされているランチャーに表示する必要があるショートカットの rank
を設定することをおすすめします。
-
ショートカットの説明の長さを制限する
-
ランチャーのアプリのショートカットを表示するメニューのスペースは限られています。可能であれば、ショートカットの「短い説明」の長さは 10 文字以下にし、「長い説明」の長さは 25 文字以下にしてください。
静的ショートカットのラベルの詳細については、属性値のカスタマイズをご覧ください。動的ショートカットと固定ショートカットについては、setLongLabel()
と setShortLabel()
のリファレンス ドキュメントをご覧ください。
-
ショートカットとアクションの使用履歴を管理する
-
作成するショートカットごとに、ユーザーがアプリ内で同じタスクを直接実行するためのさまざまな方法を検討します。このような状況のそれぞれで reportShortcutUsed()
を呼び出して、ユーザーがショートカットを表すアクションを実行する頻度の正確な履歴をランチャーで保持します。
-
ショートカットの内容が保持される場合にのみショートカットを更新する
-
動的ショートカットと固定ショートカットを変更する場合、その意味を保持するショートカットの情報を変更する場合にのみ、updateShortcuts()
を呼び出します。それ以外の場合は、再作成するショートカットの種類に応じて、次のいずれかの方法を使用します。
たとえば、スーパーマーケットに移動するショートカットを作成する場合、スーパーマーケットの名前が変更されても場所が変わらない場合は、ショートカットを更新するのが適切です。ただし、ユーザーが別のスーパーマーケットで買い物を始めた場合は、新しいショートカットを作成することをおすすめします。
-
アプリを起動するたびに動的ショートカットを確認する
-
動的ショートカットは、ユーザーが新しいデバイスにデータを復元する際に保持されません。このため、バックアップと復元のコード スニペットに示すように、アプリを起動するたびに getDynamicShortcuts()
から返されるオブジェクトの数を確認し、必要に応じて動的ショートカットを再公開することをおすすめします。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。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,["# Best practices for shortcuts\n\nWhen designing and creating your app's shortcuts, follow these guidelines:\n\n\n**Follow the design guidelines**\n\n: To make your app's shortcuts visually consistent with the shortcuts used for system apps, follow\n the\n [App Shortcuts Icon Design Guidelines](/static/shareables/design/app-shortcuts-design-guidelines.pdf).\n\n\n**Publish only four distinct shortcuts**\n\n: Although the API supports a combination of up to 15 static and dynamic shortcuts for your app, we\n recommend that you publish only four distinct shortcuts, to improve their visual appearance in the\n launcher.\n\n In addition to displaying shortcuts on the launcher, use the\n [Google Shortcuts Integration Library](/develop/ui/views/launch/shortcuts/creating-shortcuts#gsi-library)\n to display shortcuts on Google surfaces such as Google Assistant. This library supports pushing an\n unlimited number of dynamic shortcuts. If you are using this library to push a large number of\n shortcuts, we recommend setting the `rank` of the shortcuts that must appear in supported\n launchers by calling the\n [](/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setRank(int))`setRank()`\n method.\n\n\n**Limit shortcut description length**\n\n: The space in the menu that shows your app's shortcuts in the launcher is limited. When possible,\n limit the length of the \"short description\" of a shortcut to 10 characters and limit the length of\n the \"long description\" to 25 characters.\n\n For more information about labels for static shortcuts, read\n [Customize attribute values](/guide/topics/ui/shortcuts/creating-shortcuts#attribute-values).\n For dynamic and pinned shortcuts, read the reference documentation on\n [setLongLabel()](/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setLongLabel(java.lang.CharSequence))\n and\n [setShortLabel()](/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setShortLabel(java.lang.CharSequence)).\n\n\n**Maintain shortcut and action usage history**\n\n: For each shortcut you create, consider the different ways a user can accomplish the same task\n directly within your app. Call\n [reportShortcutUsed()](/reference/androidx/core/content/pm/ShortcutManagerCompat#reportShortcutUsed(android.content.Context,%20java.lang.String))\n in each of these situations so that the launcher maintains an accurate history of how frequently a\n user performs the actions representing your shortcuts.\n\n\n**Update shortcuts only when their meaning is retained**\n\n: When changing dynamic and pinned shortcuts, only call\n [updateShortcuts()](/reference/androidx/core/content/pm/ShortcutManagerCompat#updateShortcuts(android.content.Context,%20java.util.List%3Candroidx.core.content.pm.ShortcutInfoCompat%3E))\n when changing the information of a shortcut that retains its meaning. Otherwise, use one of the\n following methods, depending on the type of shortcut you're recreating:\n\n - Dynamic shortcuts: [pushDynamicShortcut()](/reference/androidx/core/content/pm/ShortcutManagerCompat#pushDynamicShortcut(android.content.Context,%20androidx.core.content.pm.ShortcutInfoCompat)).\n - Pinned shortcuts: [requestPinShortcut()](/reference/androidx/core/content/pm/ShortcutManagerCompat#requestPinShortcut(android.content.Context,%20androidx.core.content.pm.ShortcutInfoCompat,%20android.content.IntentSender)).\n\n For example, if you create a shortcut for navigating to a supermarket, it is appropriate to\n update the shortcut if the name of the supermarket changes but its location stays the same. If the\n user begins shopping at a different supermarket location, however, it's better to create a new\n shortcut.\n\n\n**Check dynamic shortcuts whenever you launch your app**\n\n: Dynamic shortcuts aren't preserved when the user restores their data onto a new device. For this\n reason, we recommend that you check the number of objects returned by\n [getDynamicShortcuts()](/reference/androidx/core/content/pm/ShortcutManagerCompat#getDynamicShortcuts(android.content.Context))\n each time you launch your app and re-publish dynamic shortcuts as needed, as shown in the code\n snippet in\n [Backup and restore](/guide/topics/ui/shortcuts/managing-shortcuts#backup-restore)."]]