2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
AppCard 만들기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
AppCard를 만들려면 앱이 매니페스트에서 AppCardContentProvider
를 확장하는 제공자를 만들어야 합니다. AppCardContentProvider
는 기본 세부정보를 추상화하여 AppCard 생성을 용이하게 합니다.
매니페스트 선언
AppCard를 만들려면 앱이 매니페스트에서 제공자를 만들어 AppCardContentProvider
를 확장해야 합니다.
<provider android:name=".SimpleAppCardContentProvider"
android:authorities="com.example.appcard.sample.media"
android:permission="@string/host_permission"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="com.android.car.appcard.APP_CARD_PROVIDER" />
</intent-filter>
</provider>
패키지당 하나의 제공자만 정의할 수 있으며 다음 속성을 사용합니다.
android:exported="true"
android:enabled="true"
android:permission="@string/host_permission"
또는
@string/host_permission
는 AppCard 라이브러리에 있으며 시스템의 Android API 버전에 따라 권한을 정의합니다.
문자열 리소스 사용은 Gradle로 빌드할 때만 작동합니다. Soong을 사용하는 경우 적절한 리소스 한정자에 따라 문자열 리소스 값으로 명시적 문자열을 지정합니다.
(기본값) android:grantUriPermissions="false"
(기본값) android:forceUriPermissions="false"
예기치 않은 결과를 방지하려면 공급자가 android:authorities
에 하나의 권한을 정의해야 합니다.
작업 기반 인텐트 필터 com.android.car.appcard.APP_CARD_PROVIDER
선언
AppCardContentProvider 확장
이 섹션에서는 override 및 protected 최종 메서드를 설명합니다.
메서드 재정의
val authority: String
이 메서드를 사용하여 android:authorities
매니페스트 속성에 정의된 기관을 반환합니다.
fun onCreate(): Boolean
이 메서드는 super.onCreate()
를 호출해야 합니다. 이 메서드를 사용하여 AppCard가 요청될 때 설정하면 지연을 일으킬 수 있는 기능을 설정하세요.
val appCardIds: List
지원되는 AppCard ID 목록을 반환하려면 이 메서드를 사용하세요. 이 문자열은 오류를 로깅하는 데 사용되므로 각 ID를 자세히 작성하는 것이 좋습니다.
fun onAppCardAdded(String, AppCardContext): AppCard
이 메서드는 AppCard가 처음 표시될 때 호출되며 AppCard와 관련된 ID와 AppCard가 표시되는 방식에 관한 힌트를 제공하는 AppCardContext
을 제공합니다.
이 메서드를 사용하여 제공자로 지원되는 AppCards에 필요한 기능을 설정합니다. 이 함수가 호출되면 지정된 ID에 해당하는 AppCard가 활성으로 간주됩니다.
fun onAppCardRemoved(String)
이 메서드는 사용자에게 표시되는 AppCard 인스턴스가 남아 있지 않을 때 호출되며 모든 정리 작업을 처리합니다. 이 함수가 호출되면 지정된 ID에 해당하는 AppCard가 비활성으로 간주됩니다.
fun onAppCardContextChanged(String, AppCardContext)
이 메서드는 시스템에서 AppCard가 표시되는 방식을 업데이트하고 업데이트된 AppCardContext
를 전송할 때 호출됩니다.
보호된 최종 메서드
fun sendAppCardUpdate(AppCard)
이 메서드를 호출하여 활성 AppCard의 업데이트를 대기열에 추가합니다.
fun sendAppCardComponentUpdate(String, Component)
이 메서드를 호출하여 활성 AppCard의 구성요소 업데이트를 대기열에 추가합니다. 지정된 구성요소에 EnforceFastUpdateRate
가 태그된 경우 업데이트가 즉시 전송됩니다.
FAQ
샘플 구현은 어디에 있나요?
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-09-05(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-09-05(UTC)"],[],[],null,["To create an AppCard, an app must create a provider in the manifest that extends\n`AppCardContentProvider`. The `AppCardContentProvider` abstracts away underlying\ndetails to facilitate the creation of AppCards.\n\nManifest declaration\n\nTo create an AppCard, an app must create a provider in the manifest to extend\n`AppCardContentProvider`. \n\n \u003cprovider android:name=\".SimpleAppCardContentProvider\"\n android:authorities=\"com.example.appcard.sample.media\"\n android:permission=\"@string/host_permission\"\n android:exported=\"true\"\n android:enabled=\"true\"\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"com.android.car.appcard.APP_CARD_PROVIDER\" /\u003e\n \u003c/intent-filter\u003e\n \u003c/provider\u003e\n\n**Only one provider can be defined per package** and with these properties:\n\n- `android:exported=\"true\"`\n- `android:enabled=\"true\"`\n- `android:permission=\"@string/host_permission\"`\n\n OR,\n - `android:readPermission=\"@string/host_permission\"`\n\n AND,\n\n `android:writePermission=\"@string/host_permission\"`\n- `@string/host_permission` exists in the AppCard library and defines a\n permission depending on the Android API version of the system.\n\n Using the string resource works only when building with Gradle. When using\n Soong, specify the explicit string with the string resource value according\n to the appropriate resource qualifier.\n- (*default* ) `android:grantUriPermissions=\"false\"`\n\n- (*default* ) `android:forceUriPermissions=\"false\"`\n\n To avoid unexpected results, it's required that the provider define a single\n authority **only** in `android:authorities`.\n- Declare an action-based intent filter,\n `com.android.car.appcard.APP_CARD_PROVIDER`\n\nExtend AppCardContentProvider\n\nThis section describes **override** and **protected** final methods.\n\nOverride methods\n\n\u003cbr /\u003e\n\n`val authority: String` Use this method to return the authority defined in the `android:authorities` manifest property.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onCreate(): Boolean` This method must call `super.onCreate()`. Use this method to set up functionality that could potentially cause a delay if set up when an AppCard is requested.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`val appCardIds: List` Use this method to return the list of supported AppCard IDs. We recommend making each ID verbose since this string is used to log errors.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onAppCardAdded(String, AppCardContext): AppCard` This method is called when an AppCard is shown for the first time and provides the ID related to the AppCard and the `AppCardContext` that provide hints as to how the AppCard is displayed.\n\n\u003cbr /\u003e\n\nUse this method to set up any functionality required by the AppCards\nsupported as a provider. Once this function is called, the AppCard that\ncorresponds to the given ID is considered to be **active.**\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onAppCardRemoved(String)` This method is called when no remaining instances of the AppCard are shown to the user and handles all clean up. When this function is called, the AppCard that corresponds to the given ID is considered **inactive.**\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun onAppCardContextChanged(String, AppCardContext)` This method is called when the system wants to update how an AppCard is displayed and sends an updated `AppCardContext`.\n\n\u003cbr /\u003e\n\nProtected final methods\n\n\u003cbr /\u003e\n\n`fun sendAppCardUpdate(AppCard)` Invoke this method to queue an update for an active AppCard.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n`fun sendAppCardComponentUpdate(String, Component)` Invoke this method to queue an update for a component in an active AppCard. If the given component is tagged with `EnforceFastUpdateRate`, then the update is sent immediately.\n\n\u003cbr /\u003e\n\nFAQ\n\nWhere are the sample implementations?\n\n- [Calendar AppCard](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-lib/sample-calendar-app/)\n- [Media AppCard](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-lib/sample-media-app/)\n- [Weather AppCard](https://android.googlesource.com/platform/packages/apps/Car/libs/+/refs/tags/ub-automotive-master-20250418/car-app-card-lib/sample-weather-app/)"]]