shortcuts.xml 中的功能可讓您宣告使用者在啟動應用程式時可採取的動作類型,然後直接跳到執行特定工作。舉例來說,您可以宣告 capability 元素,將應用程式內功能延伸至 Google 助理的應用程式動作,讓使用者透過 Google 助理對應用程式進行語音控制。詳情請參閱新增功能的說明文件。
捷徑限制
大多數支援的啟動器一次最多可顯示四個捷徑,包括靜態和動態捷徑。推送動態捷徑以顯示在 Google 途徑 (例如 Google 助理) 時,請使用 Google 捷徑整合資料庫,以免受到捷徑限制。
如果您選擇不使用 Google 捷徑整合資料庫,應用程式會受限於裝置當時支援的捷徑數量限制。以這種方式發布的捷徑只會顯示在 Android 啟動器中,無法顯示在 Google 助理等 Google 途徑中。
[[["容易理解","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-26 (世界標準時間)。"],[],[],null,["# App shortcuts overview\n\nAs a developer, you can define *shortcuts* to perform specific actions\nin your app. You can display these shortcuts in a supported launcher or\nassistant---like Google Assistant---and help your users quickly start\ncommon or recommended tasks within your app.\n\nThis documentation shows you how to\n[create](/guide/topics/ui/shortcuts/creating-shortcuts) and\n[manage](/guide/topics/ui/shortcuts/managing-shortcuts) app\nshortcuts. You can also learn some\n[best practices](/guide/topics/ui/shortcuts/best-practices) to\nimprove your shortcuts.\n\nShortcut types\n--------------\n\n**Figure 1.** Using app shortcuts, you can surface key actions and instantly take users deep into your app.\n\nEach shortcut references one or more\n[intents](/guide/components/intents-filters), each of which\nlaunches a specific action in your app when users select the shortcut. The\ntypes of shortcuts you create for your app depend on the app's use case.\nExamples of actions you can express as shortcuts include the following:\n\n- Composing a new email in an email app.\n- Navigating users to a particular location in a mapping app.\n- Sending messages to a user's contact in a communication app.\n- Playing the next episode of a TV show in a media app.\n- Loading the last save point in a gaming app.\n- Letting the user order a drink in a delivery app using spoken commands.\n\n| **Note:** Only main activities---activities that handle the [Intent.ACTION_MAIN](/reference/android/content/Intent#ACTION_MAIN) action and the [Intent.CATEGORY_LAUNCHER](/reference/android/content/Intent#CATEGORY_LAUNCHER) category---can have shortcuts. If an app has multiple main activities, define the set of shortcuts for each activity.\n\nYou can publish the following types of shortcuts for your app:\n\n- *Static shortcuts* are defined in a resource file that is packaged into an APK or [app bundle](/guide/app-bundle/build).\n- *Dynamic shortcuts* can be pushed, updated, and removed by your app only at runtime.\n- *Pinned shortcuts* can be added to supported launchers at runtime if the user grants permission. **Note:** Users can also create pinned shortcuts by copying your app's static and dynamic shortcuts onto the launcher.\n\nDisplay shortcuts in assistants using capabilities\n--------------------------------------------------\n\n*Capabilities* in `shortcuts.xml` let you declare the types\nof actions users can take to launch your app and jump directly to performing a\nspecific task. For example, you can give users voice control of your app through\nGoogle Assistant by declaring `capability` elements that extend your\nin-app functionality to Assistant\n[App\nActions](https://developer.android.com/guide/app-actions/overview#app_actions). For more details, see the documentation about\n[adding\ncapabilities](/guide/topics/ui/shortcuts/adding-capabilities).\n\nShortcut limitations\n--------------------\n\nMost supported launchers display up to four shortcuts at a time, including\nboth static and dynamic shortcuts. When pushing dynamic shortcuts for display on\nGoogle's surfaces, such as Google Assistant, use the\n[Google\nShortcuts Integration Library](/guide/topics/ui/shortcuts/creating-shortcuts#gsi-library) to avoid being subject to the shortcut\nlimit.\n\nIf you choose not to use the Google Shortcuts Integration Library, your app\nis subject to the device's limit for the number of shortcuts it supports at a\ntime. Shortcuts published this way only appear within the Android launchers and\naren't discoverable on Google surfaces such as Assistant.\n| **Note:** The maximum number of shortcuts a device supports varies. Use the [`getMaxShortcutCountPerActivity()`](//developer.android.com/reference/androidx/core/content/pm/ShortcutManagerCompat#getMaxShortcutCountPerActivity(android.content.Context)) method to determine how many shortcuts a particular device supports.\n\nThere is no limit to the number of pinned shortcuts users can create to your\napp. Your app can't remove pinned shortcuts, but it can\n[disable](/guide/topics/ui/shortcuts/managing-shortcuts#disable-shortcuts)\nthem.\n| **Note:** Although other apps can't access the metadata within your shortcuts, the launcher itself can access this data. Therefore, conceal sensitive user information in this metadata.\n\nTo start creating shortcuts for your app, refer to the following\ndocumentation:\n\n- [Create shortcuts](/guide/topics/ui/shortcuts/creating-shortcuts)\n- [Manage shortcuts](/guide/topics/ui/shortcuts/managing-shortcuts)\n- [Best practices for\n shortcuts](/guide/topics/ui/shortcuts/best-practices)\n\nFor more details about operations you can perform on shortcuts, see the\n[ShortcutManager](/reference/android/content/pm/ShortcutManager)\nAPI reference documentation."]]