2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
AppCard 호스트 구성
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
AppCardHost
를 사용하여 앱 카드를 표시하는 앱과 통신합니다.
권한
AppCardHost
를 사용하는 모든 앱에는 다음 권한이 있어야 합니다.
android.permission.INTERACT_ACROSS_USERS_FULL
android.permission.QUERY_ALL_PACKAGES
- (API 수준 34 이상 만 해당)
android.car.permission.BIND_APP_CARD_PROVIDER
초기화
호스트를 초기화하려면 다음을 제공합니다.
- 컨텍스트
updateRate
AppCard 업데이트 속도(밀리초)입니다.
fastUpdateRate
EnforceFastUpdateRate
태그가 지정된 구성요소의 업데이트 빈도(밀리초)
responseExecutor
AppCard 앱의 응답을 수신하려는 대화목록입니다.
디자인
AppCardHost
은 다음 두 가지 방법 중 하나로 상호작용할 수 있습니다.
또는
AppCardListener
AppCardListener
구성요소는 AppCardHost
에 자체를 등록하여 AppCardHost
및 AppCard 앱의 커뮤니케이션 업데이트를 수신합니다.
AppCardListener
의 인터페이스 함수는 여기에 자세히 설명되어 있습니다.
fun onAppCardReceived(AppCardContainer)
이 함수는 앱에서 AppCard를 수신하면 트리거됩니다. AppCard와 AppCard를 전송한 앱을 식별하는 appIdentifier
를 제공하는 AppCardContainer
로 전송됩니다.
fun onComponentReceived(AppCardComponentContainer)
이 함수는 앱에서 AppCard 구성요소를 수신할 때 트리거됩니다. AppCard 구성요소, AppCard를 전송한 앱을 식별하는 Identifier
, 구성요소가 연결된 AppCard를 가리키는 문자열 ID를 제공하는 AppCardComponentContainer
로 전송됩니다.
fun onProviderRemoved(String, String?)
이 함수는 AppCard 제공업체가 삭제되거나 사용 중지될 때 트리거됩니다. 이 메서드를 사용하여 지정된 패키지 이름 및 제공업체 권한과 관련된 활성 AppCard를 정리합니다.
authority가 {@code null}
이면 전체 패키지가 삭제된 것입니다.
fun onProviderAdded(String, String?)
이 함수는 앱 카드 제공업체가 추가되거나 사용 설정될 때 트리거됩니다.
사용 예 이 함수를 트리거로 사용하여 앱 카드 선택 도구에서 사용 가능한 모든 앱 카드를 새로고침합니다. authority가 {@code null}
이면 전체 패키지가 추가된 것입니다.
fun onPackageCommunicationError(appIdentifier, Throwable)
이 함수는 AppCardHost
가 AppCard 제공업체와 통신할 때 오류가 발생하면 트리거됩니다.
사용 예 이 메서드를 사용하여 사용자가 선택한 AppCard에 오류가 발생했음을 사용자에게 표시합니다.
API
fun refreshCompatibleapp()
이 메서드는 호스트를 사용하는 활동이 재개될 때마다 호출되어야 호스트가 앱 카드를 지원하는 앱 목록을 새로고침할 수 있습니다.
fun destroy()
호스트를 사용하는 활동이 소멸될 때 호스트가 모든 연결과 내부 멤버를 정리할 수 있도록 이 메서드를 호출합니다.
fun registerListener(AppCardListener)
AppCardListener
를 등록하는 데 사용됩니다.
fun unregisterListener(AppCardListener)
AppCardListener
를 등록 취소하는 데 사용됩니다.
fun getAllAppCards(AppCardContext)
이 메서드를 호출하여 등록된 AppCardListener
에 시스템에 제공된 모든 AppCard를 제공하고 제공업체에 AppCard의 구조를 구성하는 방법에 관한 힌트를 제공하는 지정된 AppCardContext
를 제공합니다.
fun requestAppCard(AppCardContext, appIdentifier, String)
이 메서드를 호출하여 등록된 AppCardListener
에 특정 AppCard를 제공합니다. 이때 AppCard의 구조를 지정하는 방법에 관한 힌트를 제공하는 AppCardContext
를 제공합니다.
fun notifyAppCardRemoved(appIdentifier, String)
AppCard 제공업체에 AppCard가 더 이상 활성 상태가 아님을 알립니다.
fun notifyAppCardInteraction(appIdentifier, String, String, String)
AppCard가 상호작용되었다고 AppCard 제공업체에 알립니다.
지원되는 유일한 상호작용은 AppCardMessageConstants.InteractionMessageConstants.MSG_INTERACTION_ON_CLICK
로 표시되는 버튼 클릭입니다.
appIdentifier
, 앱 카드 ID, 구성요소 ID, 상호작용 ID를 사용하여 이 함수를 호출하는 onClick
리스너가 있는 앱 카드의 버튼을 만드는 것이 좋습니다.
fun sendAppCardContextUpdate(AppCardContext, appIdentifier, String)
특정 AppCard의 AppCardContext
업데이트를 전송합니다. 예를 들어 주차 모드에서 주행 모드로 전환할 때 이 메서드를 사용하여 활성 AppCard별로 isInteractable
가 false
로 설정된 AppCardContext
업데이트를 전송합니다.
FAQ
샘플 구현은 어디에서 찾을 수 있나요?
각 AppCardContentProvider
는 몇 개의 AppCard를 지원할 수 있나요?
AppCardContentProvider
는 무제한의 AppCard를 지원할 수 있습니다.
하지만 앱 카드 수를 줄이면 성능이 저하될 수 있으므로 긍정적인 사용자 경험과 균형을 맞춰야 합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-06-26(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-06-26(UTC)"],[],[],null,["# Configure an AppCard host\n\nUse `AppCardHost` to communicate with apps that show AppCards.\n\nPermissions\n-----------\n\nAny app that uses an `AppCardHost` must have the following permissions:\n\n- `android.permission.INTERACT_ACROSS_USERS_FULL`\n- `android.permission.QUERY_ALL_PACKAGES`\n- (In API level 34 and higher **only** ) `android.car.permission.BIND_APP_CARD_PROVIDER`\n\nInitialize\n----------\n\nTo initialize the host, provide:\n\n- Context\n- `updateRate` AppCard update rate in milliseconds.\n- `fastUpdateRate` Update rate in milliseconds for components tagged with `EnforceFastUpdateRate`\n- `responseExecutor` A thread on which you want to receive responses from AppCard apps.\n\nDesign\n------\n\nAn `AppCardHost` can be interacted with in one of two ways:\n\n- Register as an [`AppCardListener`](#appcardlistener)\n\nOR,\n\n- Interact with the [`AppCardHost` APIs](#api)\n\n### AppCardListener\n\nThe `AppCardListener` component registers itself with an `AppCardHost`\nto receive communication updates from the `AppCardHost` and AppCard apps.\nThe interface functions of an `AppCardListener` are detailed here.\n\n\u003cbr /\u003e\n\n`fun onAppCardReceived(AppCardContainer)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard has been received from an app. It's sent as an `AppCardContainer` which provides an AppCard and an `appIdentifier` to identify the app that sent the AppCard\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onComponentReceived(AppCardComponentContainer)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard component is received from an app. It's sent as an `AppCardComponentContainer`, which provides an AppCards component, `Identifier` to identify the app that sent the AppCard, and a string ID to point to the AppCard to which the component is related.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onProviderRemoved(String, String?)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard provider has been removed or disabled. Use this method to clean up any active AppCard related to the given package name and provider authority.\u003cbr /\u003e\n\nIf authority is `{@code null}`, then an entire package was removed.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onProviderAdded(String, String?)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when an AppCard provider has been added or enabled.\u003cbr /\u003e\n\n**Sample usage.** Use this function as a trigger to refresh all available\nAppCards in an AppCard picker. If authority is `{@code null}`, then an entire\npackage was added.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onPackageCommunicationError(appIdentifier, Throwable)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis function is triggered when the `AppCardHost` encounters an error when communicating with an AppCard provider.\n\n\u003cbr /\u003e\n\n**Sample usage.** Use this method to show to the user that an AppCard they have\nselected has encountered an error.\n\n\u003cbr /\u003e\n\n### APIs\n\n\u003cbr /\u003e\n\n`fun refreshCompatibleapp()`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis method should be called whenever the activity that is using the host is resumed so that the host can refresh its list of apps that support AppCards.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun destroy()`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nCall this method when an activity that is using a host is destroyed so that the host can clean up all connections and internal members.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun registerListener(AppCardListener)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nUsed to register an `AppCardListener`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun unregisterListener(AppCardListener)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nUsed to unregister an `AppCardListener`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun getAllAppCards(AppCardContext)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nCall this method to supply a registered `AppCardListener` with all the AppCards provided in the system with a given `AppCardContext` that provides hints to the providers on how to structure their AppCard.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun requestAppCard(AppCardContext, appIdentifier, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nCall this method to supply a registered `AppCardListener` with a specific AppCard, given an `AppCardContext` that gives hints to the providers on how to structure their AppCard.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun notifyAppCardRemoved(appIdentifier, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nNotify an AppCard provider that its AppCard is no longer active.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun notifyAppCardInteraction(appIdentifier, String, String, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nNotify an AppCard provider that its AppCard has been interacted with. The only supported interaction is a button click, which is signified by a `AppCardMessageConstants.InteractionMessageConstants.MSG_INTERACTION_ON_CLICK`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nWe recommend creating a button for an AppCard with an `onClick` listener that calls this function with `appIdentifier`, AppCard ID, component ID, and interaction ID.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun sendAppCardContextUpdate(AppCardContext, appIdentifier, String)`\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSend an `AppCardContext` update for a specific AppCard. For example, when shifting from Park mode to Drive mode, use this method to send an `AppCardContext` update in which `isInteractable` is set to `false` for each active AppCard.\n\n\u003cbr /\u003e\n\nFAQ\n---\n\n1. Where can I find sample implementations?\n\n - [Sample host](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-host-lib/sample-host/). Shows all available AppCards in the system, along with\n testing capabilities.\n\n - DriverUI and [Pano manager](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/services/Car/car_product/distant_display/apps/CarDistantDisplayPanoManager/;l=1?q=CarDistantDisplayPanoManager&sq=&ss=android%2Fplatform%2Fsuperproject%2Fmain). Pano manager acts as the picker while\n DriverUI acts as the presenter.\n\n2. How many AppCards can each `AppCardContentProvider` support?\n\n An `AppCardContentProvider` can support an infinite number of AppCards.\n However, be sure to balance the number of AppCards with degraded performance\n versus a positive user experience."]]