어시스턴트에 동적 바로가기 푸시
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 바로가기는 사용자에게 앱에서 작업을 실행하거나 콘텐츠에 액세스하는 빠른 방법을 제공합니다. 어시스턴트는 적절한 때에 Android 동적 바로가기를 사용자에게 사전에 추천할 수 있으므로 사용자가 음성 지원 기능을 쉽게 검색하고 재생할 수 있습니다.
예를 들어 사용자가 메모 앱에서 만드는 각 메모의 바로가기를 푸시할 수 있습니다. 프로젝트에 Google 바로가기 통합 Jetpack 라이브러리를 추가하여 동적 링크가 어시스턴트와 같은 Google 표시 경로에 표시되도록 할 수 있습니다.
이 라이브러리를 사용하면 개발자가
ShortcutManagerCompat
클래스:
ShortcutManager
API
앱에서 Google 바로가기 통합 라이브러리를 사용하면 Google에 푸시하는 동적 바로가기가 어시스턴트 앱에서 음성 바로가기 추천으로 사용자에게 표시됩니다. ShortcutManagerCompat
라이브러리의 pushDynamicShortcut()
메서드를 사용하여 어시스턴트에 동적 바로가기를 무제한으로 푸시할 수 있습니다.
앱에 동적 바로가기 기능을 추가하려면
Android Jetpack 라이브러리인 Google 바로가기 통합 라이브러리
이 섹션에서는 이 라이브러리를 포함하도록 앱 개발 프로젝트를 구성하는 방법을 설명합니다.
이 Jetpack 라이브러리를 추가하고 프로젝트를 구성하려면 다음 단계를 따르세요.
gradle.properties
파일을 업데이트하여 Jetpack 라이브러리를 처리합니다.
gradle.properties
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
build.gradle
에 Jetpack 라이브러리 종속 항목을 추가합니다.
app/build.gradle
dependencies {
implementation "androidx.core:core:1.6.0"
implementation "androidx.core:core-google-shortcuts:1.0.1"
...
}
위의 샘플 코드에서는 Jetpack 라이브러리 두 개를 종속 항목으로 나열합니다. androidx.core:core:1.6.0
라이브러리에는 동적 바로가기를 Google에 푸시하는 데 사용하는 ShortcutManagerCompat
클래스가 포함되어 있습니다.
androidx.core:core-google-shortcuts:1.0.1
은 Google 바로가기 통합 라이브러리입니다. 이 라이브러리에는 개발자 대상 API가 포함되어 있지 않습니다. 이를 종속 항목으로 추가하면 어시스턴트가
ShortcutManagerCompat
클래스를 사용하여 푸시한 동적 바로가기
동적 바로가기 푸시
어시스턴트에 표시할 수 있는 동적 바로가기를 푸시하려면 다음 단계를 따르세요.
먼저 ShortcutInfoCompat.Builder()
클래스에 대해 자세히 알아보세요.
그런 다음 ShortcutManagerCompat.pushDynamicShortcut()
메서드를 사용하여 바로가기를 푸시합니다. 바로가기 푸시됨
사용자가 앱에서 관련 액션을 완료할 때마다 추적 다음 샘플
코드는 사용자가 메모 및 목록 앱에서 목록을 만들 때마다 바로가기를 푸시합니다.
ExampleOrderActivity
Kotlin
// Define the dynamic shortcut for an item
var intent = Intent(context, DisplayOrderActivity::class.java)
intent.action = Intent.ACTION_VIEW
var shortcutInfo = ShortcutInfoCompat.Builder(context, id)
.setShortLabel("Running")
.setLongLabel("Start running")
.addCapabilityBinding(
"actions.intent.CREATE_ITEM_LIST", "itemList.name", Arrays.asList("My First List")
)
.setIntent(intent) // Push the shortcut
.build()
// Push the shortcut
ShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo)
자바
// Define the dynamic shortcut for an item
Intent intent = new Intent(context, DisplayOrderActivity.class);
intent.setAction(Intent.ACTION_VIEW);
ShortcutInfoCompat.Builder shortcutInfo = new ShortcutInfoCompat.Builder(context, id)
.setShortLabel("Running")
.setLongLabel("Start running")
.addCapabilityBinding(
"actions.intent.CREATE_ITEM_LIST", "itemList.name", Arrays.asList("My First List"))
.setIntent(intent)
.build();
// Push the shortcut
ShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo);
위의 샘플 코드에서 ShortcutInfoCompat.Builder
메서드에서 참조된 id
는 결과 바로가기 객체의 shortcutId
를 정의합니다. 이 id
는 고유한 문자열 리터럴이어야 합니다. 자세한 내용은 Android 바로가기 문서를 참고하세요.
위의 예에서 addCapabilityBinding
메서드는 동적 바로가기를 shortcuts.xml
에서 정의된 동일한 android:name
의 capability
에 바인딩합니다. 이 메서드를 사용하면 바로가기를 시맨틱 기본 제공 인텐트(BII) 매개변수에 연결할 수 있습니다.
동적 바로가기가 특정 BII 매개변수 없이 푸시되는 경우가 있음
연결 사용자가 호출하면 어시스턴트는 바로가기에 정의된 intent
를 트리거하여 작업을 처리합니다. 다음 예는 매개변수 연결이 없는 동적 바로가기를 보여줍니다.
Kotlin
var intent: Intent = Intent(context, DisplayOrderActivity::class.java)
intent.setPackage(this, "com.sample.app")
intent.setAction(Intent.ACTION_VIEW)
var shortcutInfo: ShortcutInfoCompat = ShortcutInfoCompat.Builder(context, id)
.setShortLabel("Create a list")
.setLongLabel("Create a list")
.addCapabilityBinding("actions.intent.CREATE_ITEM_LIST")
.setIntent(intent)
.build()
ShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo);
자바
Intent intent = new Intent(context, DisplayOrderActivity.class);
intent.setPackage(this, "com.sample.app");
intent.setAction(Intent.ACTION_VIEW);
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(context, id)
.setShortLabel("Create a list")
.setLongLabel("Create a list")
.addCapabilityBinding("actions.intent.CREATE_ITEM_LIST")
.setIntent(intent)
.build();
ShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo);
어시스턴트로 동적 바로가기 테스트
Google 어시스턴트가
단축키는 목록에서 음성 바로가기 추천으로
어시스턴트 Android 앱 어시스턴트 앱에서 최근 단축어 추천
확인할 수 있습니다.
어시스턴트로 동적 바로가기를 테스트하려면 다음 단계를 따르세요.
- 앱 작업의 미리보기를 만들고 테스트 기기를 준비합니다.
다음과 같이 동일한 방식으로 작업을 테스트하기 위한 에뮬레이터
Google 어시스턴트 플러그인 설정 요구사항
- 앱을 열고 푸시할 동적 바로가기를 정의합니다. 작업을 완료합니다.
예를 들어 메모 작성 앱에 메모가 생성될 때마다 바로가기를 푸시하는 경우 새 메모를 만듭니다.
- 기기의 어시스턴트 설정 앱에서 바로가기를 엽니다. 내
앱 목록에 동적 바로가기가 표시됩니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 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,["# Push dynamic shortcuts to Assistant\n\n[Android shortcuts](/guide/topics/ui/shortcuts) provide users with quick\nmethods to perform an action or access content in an app.\nAssistant can proactively suggest your Android dynamic shortcuts to users at\nrelevant times, enabling users to easily discover and replay your\nvoice-enabled functionality.\n\nFor example, you can push a shortcut for each note a user creates in\nyour note taking app. You make\ndynamic links eligible to display on Google surfaces, like Assistant,\nby adding the [Google Shortcuts Integration Jetpack library](/jetpack/androidx/releases/core#core-google-shortcuts-1.0.1) to your project.\nThis library lets Assistant take in dynamic shortcuts you push using the\n[`ShortcutManagerCompat`](/reference/androidx/core/content/pm/ShortcutManagerCompat) class, which is a Jetpack wrapper for the\n[`ShortcutManager`](/reference/android/content/pm/ShortcutManager) API.\n\nWhen you use the Google Shortcuts Integration library in your app, dynamic\nshortcuts you push to Google are visible to users as voice shortcut suggestions\nin the Assistant app. You can push an unlimited number of dynamic shortcuts to\nAssistant using the [`pushDynamicShortcut()`](/reference/androidx/core/content/pm/ShortcutManagerCompat#pushDynamicShortcut(android.content.Context,%20androidx.core.content.pm.ShortcutInfoCompat)) method of the\n`ShortcutManagerCompat` library.\n\nConfigure your development project\n----------------------------------\n\nAdding dynamic shortcuts functionality to your app requires the\nGoogle Shortcuts Integration library, which is an Android Jetpack library.\nThis section describes how to configure your app development project to include\nthis library.\n\nTo add this Jetpack library and configure your project, follow these steps:\n\n1. Update your `gradle.properties` file to handle Jetpack libraries:\n\n **gradle.properties** \n\n android.useAndroidX=true\n # Automatically convert third-party libraries to use AndroidX\n android.enableJetifier=true\n\n2. Add the Jetpack library dependencies to your `build.gradle`:\n\n **app/build.gradle** \n\n dependencies {\n implementation \"androidx.core:core:1.6.0\"\n implementation \"androidx.core:core-google-shortcuts:1.0.1\"\n ...\n }\n\n In the preceding sample code, you list two Jetpack libraries as\n dependencies. The `androidx.core:core:1.6.0` library contains the\n `ShortcutManagerCompat` class, which you use to push dynamic shortcuts to\n Google.\n\n The `androidx.core:core-google-shortcuts:1.0.1` is the Google\n Shortcuts Integration library. This library contains no developer-facing\n API. By adding it as a dependency, you enable Assistant to take in the\n dynamic shortcuts you push using the `ShortcutManagerCompat` class.\n | **Note:** Visit the [Jetpack library explorer](/jetpack/androidx/explorer) to find the latest versions of the Core and Google Shortcuts Integration libraries.\n\nPush dynamic shortcuts\n----------------------\n\nTo push dynamic shortcuts that are eligible for display on Assistant,\nyou first create the shortcut using the `ShortcutInfoCompat.Builder()`\nclass.\n\nYou then push the shortcut using the\n`ShortcutManagerCompat.pushDynamicShortcut()` method. Shortcuts are pushed\nwhenever a user completes a relevant action in your app. The following sample\ncode pushes a shortcut every time a user creates a list in a notes and lists app.\n\n**ExampleOrderActivity** \n\n### Kotlin\n\n```kotlin\n// Define the dynamic shortcut for an item\nvar intent = Intent(context, DisplayOrderActivity::class.java)\nintent.action = Intent.ACTION_VIEW\nvar shortcutInfo = ShortcutInfoCompat.Builder(context, id)\n .setShortLabel(\"Running\")\n .setLongLabel(\"Start running\")\n .addCapabilityBinding(\n \"actions.intent.CREATE_ITEM_LIST\", \"itemList.name\", Arrays.asList(\"My First List\")\n )\n .setIntent(intent) // Push the shortcut\n .build()\n\n// Push the shortcut\nShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo)\n```\n\n### Java\n\n```java\n// Define the dynamic shortcut for an item\nIntent intent = new Intent(context, DisplayOrderActivity.class);\nintent.setAction(Intent.ACTION_VIEW);\n\nShortcutInfoCompat.Builder shortcutInfo = new ShortcutInfoCompat.Builder(context, id)\n .setShortLabel(\"Running\")\n .setLongLabel(\"Start running\")\n .addCapabilityBinding(\n \"actions.intent.CREATE_ITEM_LIST\", \"itemList.name\", Arrays.asList(\"My First List\"))\n .setIntent(intent)\n .build();\n\n// Push the shortcut\nShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo);\n```\n\nThe `id` referenced in the `ShortcutInfoCompat.Builder` method in the preceding\nsample code defines the `shortcutId` of the resulting shortcut object. This `id`\nmust be a unique string literal. For details, see the\n[Android Shortcuts documentation](/reference/android/content/pm/ShortcutInfo#getId()).\n\nIn the preceding example, the `addCapabilityBinding` method binds the dynamic\nshortcut to a `capability` of the same `android:name` defined in\n`shortcuts.xml`. This method lets you associate the shortcut to a\nsemantic [built-in intent](/guide/app-actions/intents) (BII) parameter.\n\nDynamic shortcuts sometimes are pushed without any particular BII parameter\nassociation. When invoked by the user, Assistant triggers the `intent` defined\nin the shortcut to fulfill the action. The following example shows a dynamic\nshortcut with no parameter association: \n\n### Kotlin\n\n```kotlin\nvar intent: Intent = Intent(context, DisplayOrderActivity::class.java)\nintent.setPackage(this, \"com.sample.app\")\nintent.setAction(Intent.ACTION_VIEW)\n\nvar shortcutInfo: ShortcutInfoCompat = ShortcutInfoCompat.Builder(context, id)\n .setShortLabel(\"Create a list\")\n .setLongLabel(\"Create a list\")\n .addCapabilityBinding(\"actions.intent.CREATE_ITEM_LIST\")\n .setIntent(intent)\n .build()\n\nShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo);\n```\n\n### Java\n\n```java\nIntent intent = new Intent(context, DisplayOrderActivity.class);\nintent.setPackage(this, \"com.sample.app\");\nintent.setAction(Intent.ACTION_VIEW);\n\nShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(context, id)\n .setShortLabel(\"Create a list\")\n .setLongLabel(\"Create a list\")\n .addCapabilityBinding(\"actions.intent.CREATE_ITEM_LIST\")\n .setIntent(intent)\n .build();\n\nShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo);\n```\n\nTest dynamic shortcuts with Assistant\n-------------------------------------\n\nWhen Google Assistant successfully takes in a dynamic shortcut from your\napplication, the shortcut is eligible to appear as a Voice Shortcut suggestion in the\nAssistant Android app. The Assistant app suggests the most recent shortcuts\npushed by your app.\n\nTo test your dynamic shortcuts with Assistant, follow these steps:\n\n1. Create a preview of your App Actions and prepare your test device or emulator for testing actions by following the same setup requirements as for the [Google Assistant Plugin](/guide/app-actions/test-tool).\n2. Open your app and define a dynamic shortcut to push. Then complete an action. For example, if you push a shortcut whenever a note is created in your note taking app, then create a new note.\n3. Open **Shortcuts** in the **Assistant Settings** app on your device. Your dynamic shortcut appears in the list for your app."]]